/**
 * Created by Administrator on 2017/7/24 0024.
 */
import DisplayObjectContainer = egret.DisplayObjectContainer;
import Bitmap = egret.Bitmap;
import numberToBlendMode = egret.sys.numberToBlendMode;
import BitmapData = egret.BitmapData;
/**
 *
 * Created by Administrator on 2017/7/4.
 */

// var http_open: string = "http://192.168.0.129:8080";
var http_weixin: string = "http://www.mnuocom.com";
var http_open = "";
var ball: egret.Bitmap = new egret.Bitmap();//足球
var progressball: egret.Bitmap = new egret.Bitmap();//进度条
// var goalkeeper: egret.Bitmap = new Bitmap();//守门员
var goalkeeper;//守门员
// var shooter:egret.Bitmap = new Bitmap();//射手
var x1: number = 400;
var x2: number = 560;
var num: number = 0;
var adLabel: egret.TextField = new egret.TextField();
var checknum: number = 1;
var total: number = 9;
var red: egret.Bitmap = new Bitmap();
var totalnum: egret.TextField = new egret.TextField();
//充值项-5元
var recharge1: egret.Bitmap = new Bitmap();
//充值项-10元
var recharge2: egret.Bitmap = new Bitmap();
//充值项-50元
var recharge3: egret.Bitmap = new Bitmap();
var clickbtn: boolean = true; // 设置按钮不可快速点击
var clickbtns: boolean = true; // 设置按钮不可快速点击
var rechar: boolean = true;
var click_msg: boolean = true;
var object_ontouch;
var ontouch_object;
var progressBars: egret.Bitmap = new Bitmap();//全局进度条
var needle: egret.Bitmap = new Bitmap();//指针
var foot_actives;//动态射手
var hitBall_actives;//守门员顶球
var actives;//动态守门员
var pukong_actives;//扑空动作
var youshi_actives;//右边失球动作
var zuopuzhong_actives;//左边扑中;
var zuoshi_actives;//左扑空
var dingqiu2;//顶球2
var zhongzuopukong_actives;//中左扑空
var dingqiu;
var congratulations: egret.Bitmap = new Bitmap();//恭喜你
var winning: boolean = false; //输赢
var ontouch: boolean = false;
var imgUrl: String;
var catalogTips: egret.Bitmap = new Bitmap();//充值页面
var buy: egret.Bitmap = new Bitmap();
var buy10: egret.Bitmap = new Bitmap();
var buy50: egret.Bitmap = new Bitmap();
var buy500: egret.Bitmap = new Bitmap();
var buy1k: egret.Bitmap = new Bitmap();
var buy2k: egret.Bitmap = new Bitmap();
var buysome: egret.Bitmap = new Bitmap();
var song: egret.Bitmap = new Bitmap();
var zeng2: egret.Bitmap = new Bitmap();
var zeng5: egret.Bitmap = new Bitmap();
var zeng50: egret.Bitmap = new Bitmap();
var zeng100: egret.Bitmap = new Bitmap();
var zeng200: egret.Bitmap = new Bitmap();
var windows: egret.Bitmap = new Bitmap();
var bulletinBoardBtn: egret.Bitmap = new Bitmap();//公告按钮
var explain: egret.Bitmap = new Bitmap();
var buyBtn: egret.Bitmap = new Bitmap();
var catalog: egret.Bitmap = new Bitmap();
var taskBtn: egret.Bitmap = new Bitmap();
var close1: egret.Bitmap = new Bitmap();//关闭按钮
var checkmore: boolean = true;//判断more按钮，展合
var closebtn: boolean = true;//设置按钮不可点击
var closebtns: boolean = true;//设置按钮不可点击
var onexplainwindows: egret.Bitmap = new Bitmap();//版本说明
var onexplainwindows2: egret.Bitmap = new Bitmap();
var cbtn: egret.Bitmap = new Bitmap();
var title: egret.TextField = new egret.TextField();//页面title
var text1: egret.TextField = new egret.TextField();//版本号
var text2: egret.TextField = new egret.TextField();//版本内容
var receive: egret.Bitmap = new Bitmap();
var messageList: any[] = [];
// var openId :number;
var balanceMoney: number;
var data: number;
var shoot_code: number;
var mssage_num;
var newReacharge1: egret.Bitmap = new Bitmap();
var newReacharge2: egret.Bitmap = new Bitmap();
var newReacharge3: egret.Bitmap = new Bitmap();
var msglength: number;
var square: egret.Shape = new egret.Shape();
var checkFootBallBtn: boolean = false;
var begins: boolean = true;
var btnclose: boolean = true;
var moreclick: boolean = false;
var tipscontainer = new egret.DisplayObjectContainer();//提示框载体
// var winners: egret.URLLoader = new egret.URLLoader();
var cX: number;
var cY: number;
var sound: egret.Sound;
var channel: egret.SoundChannel;
// var ends:boolean = true;
var winnerchannel: egret.SoundChannel;
var clickschannel: egret.SoundChannel;
var winnsound: egret.Sound;
var clickssound: egret.Sound;
var musicplay: boolean = true;
var musictxt: egret.TextField = new egret.TextField();
var shootbtn: egret.Bitmap = new Bitmap();
var needles;//转轴角度

var moneys: number = 0;
var money_give: number = 0;

var msgheight: number = 0;

var ontouchbegin: boolean = false;
// 邮箱
var solcontainer = new eui.Group;
var container = new egret.DisplayObjectContainer();//邮箱载体
var myscrollView: egret.ScrollView = new egret.ScrollView();

var loding_actives;//页面加载动画

var clickreceives: boolean = true;
var moneyselect: number = 1;

var openId: string = "";
var commodityId;

// 玩法说明
var howToPlayGroup = new eui.Group;
var howToPlayContainer = new egret.DisplayObjectContainer();//邮箱载体
var howToPlayScrollView: egret.ScrollView = new egret.ScrollView();

// var cannotbtn:boolean = false;
var cannotbtn: boolean = true;
var musicbtns: egret.Bitmap = new Bitmap(); //音乐按钮


var goalcontainer = new egret.DisplayObjectContainer();//金币框载体
//游戏说明框载体邮箱
var playsolcontainer = new eui.Group;
var playcontainer = new egret.DisplayObjectContainer();
//版本说明框载体
var onexplainsolcontainer = new eui.Group;
var onexplaincontainer = new egret.DisplayObjectContainer();
//游戏公告框载体
var Noticesolcontainer = new eui.Group;
var Noticecontainer = new egret.DisplayObjectContainer();
// var mailboxcontainer = new egret.DisplayObjectContainer();//邮箱框载体


var rotationTimes: egret.TextField = new egret.TextField();//转盘次数
var luckcontainer = new egret.DisplayObjectContainer();//转盘框载体
var luckpic: egret.Bitmap = new Bitmap();
var luckclose: boolean = true;
var luckbtnclose: boolean = true;
var rTimes: number;
var rname: string;
// 小红点
var redspot: egret.Bitmap = new Bitmap();
//任务
var taskcontainer = new eui.Group;
var taskcontainers = new egret.DisplayObjectContainer();//任务
var mytaskscrollView: egret.ScrollView = new egret.ScrollView();
var taskmessageList: any[] = [];
var taskmsgheight: number = 0;
var taskString = RES.getRes("receive");
var taskStringWidth: number = 100;
var taskStringHeight: number = 100;


var prizesId: number;
var numberOfTurns: number;

var event_task;
var rotations;



var lucklylock:boolean;

var alertText;
var alertLength;
var bulletinBoard: egret.TextField = new egret.TextField();
var bulletinBoards = egret.Tween.get(sprs, { "loop": true });
var sprs: egret.Sprite = new egret.Sprite();
var spr: egret.Sprite = new egret.Sprite();
class football extends DisplayObjectContainer {
    private loadingView: LoadingUI;
    private sound: egret.Sound;
    private winsound: egret.Sound;
    private scroller: eui.Scroller;
    private system: eui.Component;

    // private scroller: eui.Scroller;
    // private winner: egret.Sound;
    // private scroller: eui.Scroller;//滑动



    public constructor() {
        super();
        this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
    }



    private onAddToStage(event: egret.Event) {
        egret.ImageLoader.crossOrigin = "anonymous";
        this.startLoad();//添加声音
        // this.stage.scaleMode = egret.StageScaleMode.FIXED_HEIGHT;
        // this.stage.orientation = egret.OrientationMode.LANDSCAPE;
        // this.stage.stageWidth;
        // this.stage.stageHeight;
        //设置加载进度界面
        //Config to load process interface
        this.loadingView = new LoadingUI();
        this.stage.addChild(this.loadingView);

        //初始化Resource资源加载库
        //initiate Resource loading library
        RES.addEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.onConfigComplete, this);
        RES.loadConfig("resource/default.res.json", "resource/");
    }
    private startLoad(): void {
        wx.ready(function () {
            wx.checkJsApi({
                jsApiList: ['hideMenuItems'],
                success: function (res) {
                    wx.hideMenuItems({
                        menuList: ["menuItem:copyUrl", "menuItem:share:appMessage", "menuItem:share:timeline", "menuItem:favorite", "menuItem:openWithQQBrowser", "menuItem:openWithSafari", "menuItem:share:qq", "menuItem:share:QZone", "menuItem:share:email"] // 要隐藏的菜单项，只能隐藏“传播类”和“保护类”按钮，所有menu项见附录3
                    });
                }
            })
        });
        //创建 URLLoader 对象
        var loader: egret.URLLoader = new egret.URLLoader();
        var win: egret.URLLoader = new egret.URLLoader();
        var clicksound: egret.URLLoader = new egret.URLLoader();


        //设置加载方式为声音
        loader.dataFormat = egret.URLLoaderDataFormat.SOUND;
        win.dataFormat = egret.URLLoaderDataFormat.SOUND;
        clicksound.dataFormat = egret.URLLoaderDataFormat.SOUND;

        //添加加载完成侦听
        loader.addEventListener(egret.Event.COMPLETE, this.onLoadComplete, this);
        win.addEventListener(egret.Event.COMPLETE, this.winner, this);
        clicksound.addEventListener(egret.Event.COMPLETE, this.clicksound, this);
        //音频资源放在resource文件夹下
        var url: string = "resource/sound/bgmusic.mp3";
        var request: egret.URLRequest = new egret.URLRequest(url);

        var winurl: string = "resource/sound/winner.wav";
        var winrequest: egret.URLRequest = new egret.URLRequest(winurl);

        var clickurl: string = "resource/sound/click.mp3";
        var clickrequest: egret.URLRequest = new egret.URLRequest(clickurl);


        //开始加载
        loader.load(request);
        win.load(winrequest);
        clicksound.load(clickrequest);
    }
    private soundChannel: egret.SoundChannel;
    private onLoadComplete(event: egret.Event): void {
        var loader: egret.URLLoader = <egret.URLLoader>event.target;
        //获取加载到的 Sound 对象
        sound = <egret.Sound>loader.data;
        this.sound = sound;
        channel = this.soundChannel;
        channel = sound.play(0, -1);
        //一个简单的播放按钮
        // var btn = new egret.Sprite();
        // btn.graphics.beginFill(0x18f7ff);
        // btn.graphics.drawRoundRect(0,0,80,40,5,5);
        // btn.graphics.endFill();
        // btn.touchEnabled = true;
        // btn.anchorOffsetX = btn.width / 2;
        // btn.x = this.stage.stageWidth / 2;
        // btn.anchorOffsetY = btn.height / 2;
        // btn.y = this.stage.stageHeight / 2;
        //监听按钮的触摸事件
        // btn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onTouch,this);
        // this.addChildAt(btn,999);
    }
    private winners: egret.SoundChannel;
    private winner(event: egret.Event): void {
        var loader: egret.URLLoader = <egret.URLLoader>event.target;
        //获取加载到的 Sound 对象
        winnsound = <egret.Sound>loader.data;
        this.winsound = winnsound;
        winnerchannel = this.winners;
    }
    private clicksounds: egret.SoundChannel;
    private clicksound(event: egret.Event): void {
        var loader: egret.URLLoader = <egret.URLLoader>event.target;
        //获取加载到的 Sound 对象
        clickssound = <egret.Sound>loader.data;
        this.winsound = clickssound;
        clickschannel = this.clicksounds;
    }



    // private winnerChannel: egret.SoundChannel;
    // private winner_play(event: egret.Event): void {
    //     var loader: egret.URLLoader = <egret.URLLoader>event.target;
    //     //获取加载到的 Sound 对象
    //     var sound: egret.Sound = <egret.Sound>loader.data;
    //     this.winner = sound;
    // }
    // private onTouch(event:egret.Event){
    //     var sound = this.sound;
    //     var channel:egret.SoundChannel = this.soundChannel;
    //     if(channel){
    //         //调用soundChannel对象的stop方法停止播放音频
    //         console.log(channel);
    //         channel.stop();
    //         this.soundChannel = null;
    //         return;
    //     }
    //     //使用SoundChannel播放音频
    //     channel = sound.play(0,-1);
    //     //Egret 3.0.4 新增获取音频长度 length 属性。
    //     console.log(sound.length);
    //     channel.addEventListener(egret.Event.SOUND_COMPLETE, this.onSoundComplete, this);
    //     //保存soundChannel对象
    //     this.soundChannel = channel;
    // }
    // private onSoundComplete(event: egret.Event): void {
    //     console.log("onSoundComplete");
    // }

    /**
     * 配置文件加载完成,开始预加载preload资源组。
     * configuration file loading is completed, start to pre-load the preload resource group
     */
    private onConfigComplete(event: RES.ResourceEvent): void {
        RES.removeEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.onConfigComplete, this);
        RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this);
        RES.addEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onResourceLoadError, this);
        RES.addEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this);
        RES.addEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR, this.onItemLoadError, this);
        RES.loadGroup("pic");
    }

    /**
     * preload资源组加载完成
     * Preload resource group is loaded
     */
    private onResourceLoadComplete(event: RES.ResourceEvent) {
        if (event.groupName == "pic") {
            this.stage.removeChild(this.loadingView);
            RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this);
            RES.removeEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onResourceLoadError, this);
            RES.removeEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this);
            RES.removeEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR, this.onItemLoadError, this);
            this.onloadevent();
        }
    }

    /**
     * 资源组加载出错
     *  The resource group loading failed
     */
    private onItemLoadError(event: RES.ResourceEvent) {
        console.warn("Url:" + event.resItem.url + " has failed to load");
    }

    /**
     * 资源组加载出错
     *  The resource group loading failed
     */
    private onResourceLoadError(event: RES.ResourceEvent) {
        //TODO
        console.warn("Group:" + event.groupName + " has failed to load");
        //忽略加载失败的项目
        //Ignore the loading failed projects
        this.onResourceLoadComplete(event);
    }

    /**
     * preload资源组加载进度
     * Loading process of preload resource group
     */
    private onResourceProgress(event: RES.ResourceEvent) {
        if (event.groupName == "pic") {
            this.loadingView.setProgress(event.itemsLoaded, event.itemsTotal);
        }
    }
    // 测试飞球
    // private flyball: egret.Bitmap;
    // private flyballs:egret.



    // private isMoving:boolean = false;
    private createBitmapByName(name: string): egret.Bitmap {
        var result = new egret.Bitmap();
        var texture: egret.Texture = RES.getRes(name);
        result.texture = texture;
        return result;
    }




    private onloadevent(): void {
        // alert("因有人故意使用第三方软件破坏平台平衡，导致数据出现异常，现已修复。");
        //获取接口信息--用户信息
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/foot/user/getUserOpenId", egret.HttpMethod.GET);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.onGetComplete, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);


        this.getWeiXinConfig();

        // var stageW:number = this.stage.stageWidth;
        // var stageH:number = this.stage.stageHeight;

        var teachspr: egret.Sprite = new egret.Sprite();
        teachspr.graphics.beginFill(0x000000);
        teachspr.alpha = 0.3;
        teachspr.graphics.drawRect(0, 0, 640, 1000);
        teachspr.graphics.endFill();

        //  this.luckdraw();


        // 进去的游戏说明提示框
        playcontainer.width = 400;
        playcontainer.height = 711;
        playcontainer.x = 120;
        playcontainer.y = 150;


        playsolcontainer.x = 0;
        playsolcontainer.y = 0;
        playsolcontainer.width = 335;
        playsolcontainer.height = 1500;
        var myScroller = new eui.Scroller();
        myscrollView.setContent(playsolcontainer);
        myscrollView.x = 25;
        myscrollView.y = 130;
        myscrollView.width = 350;
        myscrollView.height = 500;
        var playonexplainwindows: egret.Bitmap = new Bitmap();
        playonexplainwindows.texture = RES.getRes("playwindow_png");
        playonexplainwindows.width = 400;
        playonexplainwindows.height = 711;
        // onexplainwindows.x = -25;
        // onexplainwindows.y = 80;
        var playclosebtn: egret.Bitmap = new Bitmap();
        playclosebtn.texture = RES.getRes("close");
        playclosebtn.width = 50;
        playclosebtn.height = 50;
        playclosebtn.x = 355;
        playclosebtn.y = -5;
        playclosebtn.touchEnabled = true;
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/foot/user/getSystemSetting", egret.HttpMethod.GET);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.getSystemSetting, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
        playclosebtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.playclosebtn, this);





        //云朵123：
        var clouds1: egret.Bitmap = new Bitmap();
        clouds1.texture = RES.getRes("clouds1");
        clouds1.width = 100;
        clouds1.height = 56;
        clouds1.x = -119;
        clouds1.y = 19;
        var clouds2: egret.Bitmap = new Bitmap();
        clouds2.texture = RES.getRes("clouds2");
        clouds2.width = 200;
        clouds2.height = 96;
        clouds2.x = -282;
        clouds2.y = 52;
        var clouds3: egret.Bitmap = new Bitmap();
        clouds3.texture = RES.getRes("clouds3");
        clouds3.width = 80;
        clouds3.height = 14;
        clouds3.x = -102;
        clouds3.y = 102;
        var cl1 = egret.Tween.get(clouds1, { "loop": true });
        cl1.to({
            "x": 900
        }, 60000);
        var cl2 = egret.Tween.get(clouds2, { "loop": true });
        cl2.to({
            "x": 900
        }, 50000);
        var cl3 = egret.Tween.get(clouds3, { "loop": true });
        cl3.to({
            "x": 900
        }, 70000);
        // 测试飞球
        // this.flyball = this.createBitmapByName("football");
        // this.flyball.name = "飞球";
        // this.flyball.x = 275;
        // this.flyball.y = 750;
        // this.flyball.width = 50;
        // this.flyball.height = 50;
        // var fball =  egret.Tween.get(this).to({ factor: 1 }, 1000, egret.Ease.sineIn);

        // var spr: egret.Sprite = new egret.Sprite();
        // spr.graphics.beginFill(0x000000);
        // spr.alpha = 0.3;
        // spr.graphics.drawRect(0, 0, 640, 40);
        // spr.graphics.endFill();
        // spr.y = 210;

        // sprs.graphics.drawRect(0, 0, 640, 40);
        // sprs.graphics.endFill();
        // sprs.x = 640;
        // bulletinBoard.alpha = 10;
        // bulletinBoard.x = 0;
        // bulletinBoard.y = 10;
        // bulletinBoard.fontFamily = "KaiTi";
        // bulletinBoard.textFlow = <Array<egret.ITextElement>>[
        //     {
        //         text: "",
        //         style: { "textColor": 0xFFFFFF, "size": 20, "fontFamily": "楷体" }
        //     }
        // ];
        // bulletinBoards = egret.Tween.get(sprs, { "loop": true });
        // bulletinBoards.to({
        //     "x": -400
        // }, 20000);


        // var bulletinBoard: egret.TextField = new egret.TextField();
        // bulletinBoard.alpha = 10;
        // bulletinBoard.x = 0;
        // bulletinBoard.y = 10;
        // bulletinBoard.fontFamily = "KaiTi";
        // bulletinBoard.textFlow = <Array<egret.ITextElement>>[
        //     {
        //         text: "玩游戏增加广告金，看广告也能赚钱哦！关于广告流畅度，将于下周二深度优化更新！",
        //         style: { "textColor": 0xFFFFFF, "size": 20, "fontFamily": "楷体" }
        //     }
        // ];

        // var bulletinBoards = egret.Tween.get(sprs, { "loop": true });
        // bulletinBoards.to({
        //     "x": -1000
        // }, 10000);
        // var labas: egret.Bitmap = new Bitmap();
        // labas.texture = RES.getRes("laba_png");
        // labas.x = -40;
        // labas.y = 5;
        // labas.alpha = 10;

        // var labass = egret.Tween.get(labas, { "loop": true });
        // labass.to({
        //     "x": 900
        // }, 10000);

        catalogTips.texture = RES.getRes('rechargeBg_png');
        catalogTips.width = 0;
        catalogTips.height = 0;
        // catalogTips.height = 1024;
        catalogTips.x = 0;
        catalogTips.y = 0;
        //公告栏--喇叭
        // var horn: egret.Bitmap = new Bitmap();
        // horn.texture = RES.getRes("laba");
        // horn.x = 380;
        // horn.y = 150;
        //公告栏 -- 文字(text)
        // var bulletinBoard: egret.TextField = new egret.TextField();
        // bulletinBoard.x = 420;
        // bulletinBoard.y = 158;
        // bulletinBoard.fontFamily = "KaiTi";
        // bulletinBoard.textFlow = <Array<egret.ITextElement>>[
        //     {
        //         text: "恭喜ID888，获得1000RMB",
        //         style: { "textColor": 0xff0000, "size": 18, "strokeColor": 0x6699cc, "stroke": 2, "fontFamily": "楷体" }
        //     }
        // ];
        //官方赠送金额
        // var givemoney :egret.TextField =new egret.TextField();
        // givemoney.x = 230
        // givemoney.y = 160;
        // givemoney.textFlow = <Array<egret.ITextElement>>[
        //     {
        //         text:"官方赠送：1999",
        //         style: {"textColor": 0xf06f00, "size": 25, "fontFamily": "楷体"}
        //     }
        // ];
        //  var leaf: egret.Bitmap = new Bitmap();
        // leaf.texture = RES.getRes("clouds1");
        // leaf.width = 100;
        // leaf.height = 56;
        // leaf.x = -119;
        // leaf.y = 19;
        // var leaf_actives;
        // var leafjson = RES.getRes("Leaf_json");
        // var leafimg = RES.getRes("Leaf_png");
        // var leaf_active = new egret.MovieClipDataFactory(leafjson, leafimg);
        // leaf_actives = new egret.MovieClip(leaf_active.generateMovieClipData());
        // leaf_actives.gotoAndPlay(0, -1);
        adLabel.x = 65;
        adLabel.y = 15;
        adLabel.fontFamily = "KaiTi";
        adLabel.textFlow = <Array<egret.ITextElement>>[
            {
                text: "" + num,
                style: { "textColor": 0xf06f00, "size": 25, "strokeColor": 0x800000, "stroke": 2, "fontFamily": "楷体" }
            }
        ];

        musicbtns.texture = RES.getRes("open_music_png");
        musicbtns.width = 75;
        musicbtns.height = 75;
        musicbtns.y = 70;
        musicbtns.x = 443;

        // musictxt.x = 433;
        // musictxt.y = 160;
        // musictxt.fontFamily = "KaiTi";
        // musictxt.textFlow = <Array<egret.ITextElement>>[
        //     {
        //         text: "音乐:开",
        //         style: { "textColor": 0xf06f00, "size": 25, "strokeColor": 0x800000, "stroke": 2, "fontFamily": "楷体" }
        //     }
        // ];



        var goldBox: egret.Bitmap = new Bitmap();//金币框
        // add_png,jinbi_png
        goldBox.texture = RES.getRes("jinbi_png");
        goldBox.width = 200;
        goldBox.height = 44;
        goalcontainer.width = 200;
        goalcontainer.height = 44;
        goalcontainer.x = 75;
        goalcontainer.y = 110;


        // var addBox: egret.Bitmap = new Bitmap();//点击跳转到商城页面
        // addBox.texture = RES.getRes("add_png");
        // addBox.width = 60;
        // addBox.height = 42;
        // addBox.x = 240;
        // addBox.y = 155;
        //背景图片
        var goal: egret.Bitmap = new Bitmap();
        goal.texture = RES.getRes("goal_jpg");
        goal.width = 1151;
        goal.height = 1024;
        goal.x = -255;
        // goal.width = stageW;
        // goal.height = stageH;




        //未读数量 -- 文字(text)
        // totalnum.x = 538;
        // totalnum.y = 603;
        // totalnum.fontFamily = "KaiTi";
        // totalnum.textFlow = <Array<egret.ITextElement>>[
        //     {
        //         text: "" + total + "",
        //         style: {"textColor": 0x00ffffff, "size": 18, "fontFamily": "楷体"}
        //     }
        // ];
        //未读信息
        red.texture = RES.getRes("red");
        red.width = 50;
        red.height = 50;
        red.x = 520;
        red.y = 580;
        //信箱
        var message: egret.Bitmap = new Bitmap();
        message.texture = RES.getRes("message");
        message.width = 80;
        message.height = 100;
        message.x = 530;
        message.y = 600;
        //底部按钮 -- 踢球
        var btn1: egret.Bitmap = new Bitmap();
        btn1.texture = RES.getRes("play_football");
        btn1.width = 60;
        btn1.height = 90;
        btn1.x = 80;
        btn1.y = 920;
        //底部按钮 -- 广告
        var btn2: egret.Bitmap = new Bitmap();
        btn2.texture = RES.getRes("ad");
        btn2.width = 60;
        btn2.height = 90;
        btn2.x = 220;//80+140
        btn2.y = 920;
        //底部按钮 -- 二维码
        var btn3: egret.Bitmap = new Bitmap();
        btn3.texture = RES.getRes("code");
        btn3.width = 60;
        btn3.height = 90;
        btn3.x = 360;//80+220+140
        btn3.y = 920;
        //底部按钮 -- 客服
        // var btn4:egret.Bitmap = new Bitmap();
        // btn4.texture = RES.getRes("customerService");
        // btn4.width = 100;
        // btn4.height = 58;
        // btn4.x = 392;//369+23
        // btn4.y = 951;
        //底部按钮 -- 我的
        var btn5: egret.Bitmap = new Bitmap();
        btn5.texture = RES.getRes("my");
        btn5.width = 60;
        btn5.height = 90;
        btn5.x = 500;//440+140+80
        btn5.y = 920;
        var footbg: egret.Bitmap = new Bitmap();
        footbg.texture = RES.getRes("footerbg_png");
        footbg.width = 640;
        footbg.height = 151;
        footbg.y = 880;
        footbg.x = 0;




        //congratulations
        congratulations.texture = RES.getRes("congratulations");
        // congratulations.scaleX = 0.001;
        congratulations.anchorOffsetX = 241;
        congratulations.anchorOffsetY = 107;
        congratulations.width = 0;
        congratulations.height = 0;
        congratulations.x = 320;
        congratulations.y = 300;
        //足球 ---
        ball.texture = RES.getRes('football');
        ball.width = 60;
        ball.height = 60;
        ball.x = 275;
        ball.y = 750;

        // var flyball = egret.Tween.get(ball).to({factor:1},2000);


        // ball.skewX = 0.5;
        // ball.skewY = 0.5;
        //守门员
        var goalkeepers = RES.getRes("ball_json");
        var goalkeeper_imgs = RES.getRes("ball_img");
        var goalkeeper_active = new egret.MovieClipDataFactory(goalkeepers, goalkeeper_imgs);
        goalkeeper = new egret.MovieClip(goalkeeper_active.generateMovieClipData());
        // goalkeeper.x = 100;





        // goalkeeper.texture = RES.getRes('goalkeeper');
        // goalkeeper.width = 100;
        // goalkeeper.height = 135;
        // goalkeeper.x = 265;
        // goalkeeper.y = 370;






        //射手
        // shooter.texture = RES.getRes("shooter");
        // shooter.width = 250;
        // shooter.height = 290;
        // shooter.x = 99;
        // shooter.y = 750;
        recharge1.texture = RES.getRes("5check_png");
        recharge1.x = 30;
        recharge1.y = 800;
        recharge1.width = 50;
        recharge1.height = 50;
        // var yuan5text: egret.TextField = new egret.TextField();
        // yuan5text.width = 320;
        // yuan5text.width = 560;
        // yuan5text.x = 48;
        // yuan5text.y = 810
        // yuan5text.textFlow = <Array<egret.ITextElement>>[
        //     {
        //         text: "5",
        //         style: { "textColor": 0xFFFF00, "size": 30, "strokeColor": 0x6699cc, "stroke": 2, "fontFamily": "楷体" }
        //     }
        // ];


        recharge2.texture = RES.getRes("10_png");
        recharge2.x = 80;
        recharge2.y = 720;
        recharge2.width = 60;
        recharge2.height = 60;
        // var yuan10text: egret.TextField = new egret.TextField();
        // yuan10text.width = 320;
        // yuan10text.width = 560;
        // yuan10text.x = 95;
        // yuan10text.y = 735
        // yuan10text.textFlow = <Array<egret.ITextElement>>[
        //     {
        //         text: "10",
        //         style: { "textColor": 0xFFFF00, "size": 30, "strokeColor": 0x6699cc, "stroke": 2, "fontFamily": "楷体" }
        //     }
        // ];
        recharge3.texture = RES.getRes("50_png");
        recharge3.x = 30;
        recharge3.y = 640;
        recharge3.width = 70;
        recharge3.height = 70;
        // var yuan50text: egret.TextField = new egret.TextField();
        // yuan50text.width = 320;
        // yuan50text.width = 560;
        // yuan50text.x = 50;
        // yuan50text.y = 660
        // yuan50text.textFlow = <Array<egret.ITextElement>>[
        //     {
        //         text: "50",
        //         style: { "textColor": 0xFFFF00, "size": 30, "strokeColor": 0x6699cc, "stroke": 2, "fontFamily": "楷体" }
        //     }
        // ];
        //公告栏
        bulletinBoardBtn.texture = RES.getRes("skill");
        bulletinBoardBtn.width = 58;
        bulletinBoardBtn.height = 58;
        // bulletinBoardBtn.y = 400;
        bulletinBoardBtn.y = 80;
        bulletinBoardBtn.x = 550;
        //版本信息
        explain.texture = RES.getRes("explain");
        explain.width = 58;
        explain.height = 58;
        // explain.y = 320;
        explain.y = 80;
        explain.x = 550;
        //点击购买
        catalog.texture = RES.getRes("question");
        catalog.width = 58;
        catalog.height = 58;
        // catalog.y = 240;
        catalog.y = 80;
        catalog.x = 550;
        //目录
        buyBtn.texture = RES.getRes("catalog");
        buyBtn.width = 58;
        buyBtn.height = 58;
        // buyBtn.y = 160;
        buyBtn.y = 80;
        buyBtn.x = 550;




        // 小红点
        redspot.texture = RES.getRes("redspot_png");
        redspot.width = 20;
        redspot.height = 20;
        redspot.x = 555;
        redspot.y = 85;
        redspot.visible = false;
        //任务
        taskBtn.texture = RES.getRes("task_png");
        taskBtn.width = 58;
        taskBtn.height = 58;
        // buyBtn.y = 160;
        taskBtn.y = 80;
        taskBtn.x = 550;



        //展开选项
        var more: egret.Bitmap = new Bitmap();
        more.texture = RES.getRes("more");
        more.width = 80;
        more.height = 80;
        more.y = 70;
        more.x = 540;

        // 抽奖
        var luck: egret.Bitmap = new Bitmap();
        luck.texture = RES.getRes("luckdrawicon_png");
        luck.width = 80;
        luck.height = 80;
        luck.y = 70;
        luck.x = 330;




        //头像
        var headPortrait: egret.Bitmap = new Bitmap();
        headPortrait.texture = RES.getRes("headPortrait");
        headPortrait.width = 250;
        headPortrait.height = 104;
        headPortrait.x = 10;
        headPortrait.y = 50;
        //射球按钮

        shootbtn.texture = RES.getRes("footerball");
        shootbtn.width = 80;
        shootbtn.height = 80;
        shootbtn.y = 800;
        shootbtn.x = 480;
        //进度条上面的足球
        // progressball.texture = RES.getRes('football');
        // progressball.width = 80;
        // progressball.height = 80;
        // progressball.x = 400;
        // progressball.y = 960;
        var tws = egret.Tween.get(progressball, { "loop": true });
        tws.to({ x: x2 }, 1000).to({ x: x1 }, 1000);
        //背景图片
        // var bgImage:egret.Bitmap = new egret.Bitmap();
        // bgImage.texture = RES.getRes("bgIamge");
        // this.addChild(bgImage);
        //添加踢球动作
        var foot_json = RES.getRes("footjson");
        var foot_imgs = RES.getRes("footimg");
        var foot_active = new egret.MovieClipDataFactory(foot_json, foot_imgs);
        foot_actives = new egret.MovieClip(foot_active.generateMovieClipData());
        // //添加拳头顶球动作
        // var hitBalljson = RES.getRes("hitBall_json");
        // var hitBallimg = RES.getRes("hitBall_png");
        // var hitBall_active = new egret.MovieClipDataFactory(hitBalljson, hitBallimg);
        // hitBall_actives = new egret.MovieClip(hitBall_active.generateMovieClipData());

        ontouch_object = this;


        // title.width = 250;
        // title.x = 230;
        // title.y = 220;
        // title.textFlow = <Array<egret.ITextElement>>[
        //     {
        //         text: "游戏玩法",
        //         style: { "textColor": 0x000000, "size": 40, "strokeColor": 0x6699cc, "stroke": 2, "fontFamily": "楷体" }
        //     }
        // ];


        this.addChildAt(goal, 1);//背景
        this.addChild(shootbtn);






        this.addChildAt(goalkeeper, 3);
        goalcontainer.addChildAt(adLabel, 5);
        // this.addChildAt(goldBox,4);
        this.addChildAt(recharge1, 3);
        this.addChildAt(recharge2, 3);
        this.addChildAt(recharge3, 3);
        this.addChildAt(headPortrait, 3);
        this.addChildAt(goalcontainer, 4);
        goalcontainer.addChildAt(goldBox, 1);
        this.addChildAt(more, 4);
        this.addChildAt(luck, 4);
        this.addChildAt(musicbtns, 4);
        this.addChildAt(musictxt, 4);
        // this.addChild(givemoney);
        this.addChildAt(buyBtn, 4);
        this.addChildAt(redspot, 5);
        this.addChildAt(taskBtn, 4);
        this.addChildAt(catalog, 4);
        this.addChildAt(bulletinBoardBtn, 4);
        this.addChildAt(explain, 4);
        // this.addChildAt(pukong_actives, 999);
        this.addChildAt(clouds2, 1);
        this.addChildAt(clouds3, 1);
        this.addChildAt(clouds1, 1);
        // this.addChild(question);
        // this.addChild(catalog);
        // this.addChildAt(totalnum,4);
        this.addChildAt(message, 2);
        // this.addChild(shooter);
        //底部菜单
        this.addChildAt(footbg, 2);
        this.addChildAt(btn1, 6);//踢球
        this.addChildAt(btn2, 6);//广告
        this.addChildAt(btn3, 6);//二维码
        // this.addChildAt(btn4, 6);//收入
        this.addChildAt(btn5, 6);//我的
        // this.addChild(bulletinBoard);
        // this.addChild(horn);
        this.addChildAt(foot_actives, 6);//动态射手 --- 未执行动画
        // this.addChildAt(hitBall_actives, 4);
        // this.addChildAt(yuan5text, 30);
        // this.addChildAt(yuan10text, 30);
        // this.addChildAt(yuan50text, 30);
        this.addChildAt(ball, 5);
        this.addChildAt(congratulations, 8);//恭喜你
        this.addChildAt(catalogTips, 99);//充值页面
        // 测试飞球
        // this.addChild(this.flyball);


        this.addChildAt(playcontainer, 98);
        playcontainer.addChildAt(playonexplainwindows, 8)
        playcontainer.addChildAt(myscrollView, 9)
        playcontainer.addChildAt(playclosebtn, 9)




        // this.addChild(teachspr);
        // this.addChild(myscrollView);
        //设置按钮可点击
        recharge1.touchEnabled = true;
        recharge2.touchEnabled = true;
        recharge3.touchEnabled = true;
        shootbtn.touchEnabled = true;
        buyBtn.touchEnabled = true;
        taskBtn.touchEnabled = true;
        catalog.touchEnabled = true;
        message.touchEnabled = true;
        bulletinBoardBtn.touchEnabled = true;
        more.touchEnabled = true;
        luck.touchEnabled = true;
        btn2.touchEnabled = true;
        btn3.touchEnabled = true;
        // btn4.touchEnabled = true;
        btn5.touchEnabled = true;
        explain.touchEnabled = true;
        adLabel.touchEnabled = true;
        goldBox.touchEnabled = true;
        musicbtns.touchEnabled = true;
        //点击射球
        shootbtn.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBegin, this);
        // shootbtn.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this);
        shootbtn.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEnd, this);
        shootbtn.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchMove, this);
        // shootbtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouch, this);
        recharge1.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchrecharge1, this);
        recharge2.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchrecharge2, this);
        recharge3.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchrecharge3, this);
        catalog.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchercatalog, this);//玩法说明
        buyBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchBuy, this);//点击购买
        taskBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.gettask, this);
        message.addEventListener(egret.TouchEvent.TOUCH_TAP, this.messagetouch, this);//邮箱
        bulletinBoardBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.skillwindow, this);//技能介绍
        more.addEventListener(egret.TouchEvent.TOUCH_TAP, this.moreselect, this);//闭合
        btn2.addEventListener(egret.TouchEvent.TOUCH_TAP, this.btn2, this);//底部菜单
        btn3.addEventListener(egret.TouchEvent.TOUCH_TAP, this.btn3, this);//底部菜单
        // btn4.addEventListener(egret.TouchEvent.TOUCH_TAP, this.btn4, this);//底部菜单
        btn5.addEventListener(egret.TouchEvent.TOUCH_TAP, this.btn5, this);//底部菜单
        explain.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onexplain, this);//版本说明
        goldBox.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onMoney, this);//点击游戏币跳转到充值页面
        musicbtns.addEventListener(egret.TouchEvent.TOUCH_TAP, this.changmusic, this);
        luck.addEventListener(egret.TouchEvent.TOUCH_TAP, this.luckdraw, this);//转盘



    }
    // // 测试飞球
    // public get factor(): number {
    //     return 0;
    // }

    // public set factor(value: number) {
    //     this.flyball.x = (1 - value) * (1 - value) * 275 + 2 * value * (1 - value) * 50 + value * value * 275;
    //     this.flyball.y = (1 - value) * (1 - value) * 750 + 2 * value * (1 - value) * 425 + value * value * 350;
    //     this.flyball.width = (1 - value + 0.4) * 50;
    //     this.flyball.height = (1 - value + 0.4) * 50;
    //     // this.flyball.rotation =value * 3600;
    // }
    // // 测试飞球掉落
    // public get factor2(): number {
    //     return 0;
    // }

    // public set factor2(value: number) {
    //     this.flyball.x = (1 - value) * (1 - value) * 275 + 2 * value * (1 - value) * 270 + value * value * 265;
    //     this.flyball.y = (1 - value) * (1 - value) * 350 + 2 * value * (1 - value) * 400 + value * value * 425;
    //     // this.flyball.width = (1 - value + 0.4) * 50;
    //     // this.flyball.height = (1 - value + 0.4) * 50;
    //     // this.flyball.rotation =value * 360;
    // }




    public onTouchBegin(event: egret.TouchEvent) {
        // if (cannotbtn == false){
        //     return
        // }
        if (closebtn == false) {
            return
        }
        if(lucklylock == false){
            return
        }
        if (begins == false) {
            return;
        }
        // console.log("按下begins:"+begins);
        closebtn = false;
        ontouchbegin = true;
        // if (closebtn == false) {
        //     return
        // }
        // if (clickbtn == false ||  begins == false) {
        //     return;
        // }
        // if (checkFootBallBtn == true) {
        //     return;
        // }
        // checkFootBallBtn = true;
        // console.log("closebtn:"+closebtn);

        var buybtn = egret.Tween.get(buyBtn, { "loop": false }).to({
            "y": 80
        }, 300);
        var cataLog = egret.Tween.get(catalog, { "loop": false }).to({
            "y": 80
        }, 300);
        var bulletinBoardbtn = egret.Tween.get(bulletinBoardBtn, { "loop": false }).to({
            "y": 80
        }, 300);
        var explains = egret.Tween.get(explain, { "loop": false }).to({
            "y": 80
        }, 300);

        var redopen = egret.Tween.get(redspot, { "loop": false }).to({
            "y": 80
        }, 300);
        var taskBtnopen = egret.Tween.get(taskBtn, { "loop": false }).to({
            "y": 80
        }, 300);


        checkmore = true; //“+”号按钮
        ontouch = false;  //点击
        cX = event.stageX;
        cY = event.stageY
        if (num < 1) {
            this.addtips("游戏币不足，请充值", "s不刷新");
            begins = true;
            return;
        }
        if (num < checknum) {
            this.addtips("游戏币不足，不能选择该金额", "s不刷新");
            begins = true;
            return;
        }
        // if (clickbtn == false || closebtn == false || begins == false) {
        //     return;
        // }
        begins = false;
        // ontouch = clickbtn;
        // closebtn = false;
        //添加进度条框和指针
        //添加指针
        needle.texture = RES.getRes("needle");
        needle.x = 520;
        needle.y = 850;
        needle.anchorOffsetX = 120;
        needle.anchorOffsetY = 7;
        needle.rotation = 0;
        needles = egret.Tween.get(needle, { "loop": true });
        needles.to({
            "rotation": 180
        }, 300).to({
            "rotation": 0
        }, 300);
        //精准条；（能量条）
        progressBars.texture = RES.getRes("progressBar");
        progressBars.width = 250;
        progressBars.height = 135;
        progressBars.x = 400;
        progressBars.y = 730;
        this.addChildAt(progressBars, 1);
        this.addChildAt(needle, 2);
    }
    private touchMove(event: egret.TouchEvent): void {
        // if (cannotbtn == false){
        //     return
        // }

        if (begins == true) {
            return
        }
        if (ontouchbegin == false) {
            return;
        }

        // console.log("移动begins:"+begins);
        // console.log("移开");
        // if (checkFootBallBtn == false) {
        //     return;
        // }
        closebtn = true;
        begins = true;

        this.removeChild(progressBars);
        this.removeChild(needle);
    }
    private onTouchEnd(event: egret.TouchEvent) {
        // if (cannotbtn == false){
        //     return
        // }
        // if (closebtn == false) {
        //     return
        // }
        if (begins == true) {
            return;
        }
        if (clickbtns = false) {
            return;
        }
        if(lucklylock == false){
            return
        }
        if (ontouchbegin == false) {
            return;
        }
        ontouchbegin = false;
        clickbtns = false;
        // console.log("抬起begins:"+begins);
        // console.log("抬起");
        closebtn = false;
        begins = false;
        // shootbtn.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this);
        // if (checkFootBallBtn == false) {
        //     return;
        // }
        var ods = Math.round(needle.rotation / 180 * 100)
        // checkFootBallBtn = false;
        rechar = false;
        // console.log(begins);
        // console.log("判断前====离开：clickbtn："+clickbtn +"----ontouch:"+ontouch);
        // if (clickbtn == ontouch && clickbtn == true) {
        //     clickbtn = false;
        // console.log("判断后====离开：clickbtn："+clickbtn +"----ontouch:"+ontouch);
        egret.Tween.pauseTweens(needle);//点击射球后暂停动画
        //判断余额是否充足
        if (num < 1) {
            this.addtips("游戏币不足，请充值", "s不刷新");
            // alert("游戏币不足，请充值","不刷新");
            // begins = true;
            // this.buyMoney();
            return;
        }
        if (num < checknum) {
            this.addtips("游戏币不足，不能选择该金额", "s不刷新");
            // alert("游戏币不足，不能选择该金额");
            begins = true;
            // this.buyMoney();
            return;
        }
        num = num - checknum;
        var nums_t = Math.floor(num * 100) / 100
        adLabel.x = 65;
        adLabel.y = 15;
        adLabel.fontFamily = "KaiTi";
        adLabel.textFlow = <Array<egret.ITextElement>>[
            {
                text: "" + nums_t,
                style: { "textColor": 0xf06f00, "size": 25, "strokeColor": 0x800000, "stroke": 2, "fontFamily": "楷体" }
            }
        ];
        var tws = egret.Tween.get(adLabel, { "loop": false }).to({
            "scaleX": 1.2,
            "scaleY": 1.2
        }, 600).wait(100);
        tws.to({
            "scaleX": 1,
            "scaleY": 1
        }, 600);
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/foot/user/setKickBallRecord?betAmount=" + moneyselect + "&odds=" + ods, egret.HttpMethod.POST);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.shootball, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
        /***
         * 下面代码是足球运动轨迹
         */
        // } else {
        //     return;
        // }
    }
    private shootball(event: egret.Event): void {
        var requests = <egret.HttpRequest>event.currentTarget;
        var req = JSON.parse(requests.response);//转为JSON格式
        // console.log(req);
        if (req.error_code == 2) {
            this.addtips("余额不足", "s不刷新")
            return;
        }
        data = req.data.amountMoney;
        shoot_code = req.error_code;
        balanceMoney = req.data.money
        var leftX;
        var flyto;
        object_ontouch = this;
        // ontouch_object.removeChild(shooter);
        foot_actives.gotoAndPlay(0, 1);
        // var probability = Math.floor(Math.random() * 2);
        var nou = Math.random() * 4;
        var probability = parseInt("" + nou);
        // var probability = 0;
        // shoot_code = 1;
        var fly = Math.floor(Math.random() * 2);
        if (probability == 0) {
            if (shoot_code == 1) {//判读0或者1 不同方向left ---- right  接到球
                // console.log("动画1------向右接球翻滚");
                winning = false;
                leftX = 460;  //right
                //球飞出动作
                var tw = egret.Tween.get(ball, { "loop": false }).wait(920).call(function () {
                    object_ontouch.removeChild(goalkeeper);
                    object_ontouch.addChild(actives);
                    actives.gotoAndPlay(0, 1);
                }).to({
                    "x": leftX,
                    "y": 440,
                    "width": 20,
                    "height": 20,
                }, 700).wait(100)
                    .to({
                        "x": leftX,
                        "y": 735,
                        "width": 0,
                        "height": 0
                    }, 1);
                this.ondatas(1);
                // this.ondatas(3);
            } else {   //未接到球
                // console.log("动画2-------向右失球");
                winning = true;
                leftX = 480;//left
                //移除静态守门员
                //球飞出动作
                var tw = egret.Tween.get(ball, { "loop": false }).wait(920).call(function () {
                    object_ontouch.removeChild(goalkeeper);
                    object_ontouch.addChild(youshi_actives)
                    youshi_actives.gotoAndPlay(0, 1);
                }).to({
                    "x": leftX,
                    "y": 330,
                    "width": 20,
                    "height": 20,
                }, 500)
                    .wait(100)
                    .to({
                        "x": 480,
                        "y": 350,
                        "width": 20,
                        "height": 20
                    }, 150)
                    .to({
                        "x": 470,
                        "y": 410,
                        "width": 20,
                        "height": 20
                    }, 120)
                    .to({
                        "x": 470,
                        "y": 450,
                        "width": 20,
                        "height": 20,
                    }, 120)
                    .to({
                        "x": 460,
                        "y": 420,
                        "width": 20,
                        "height": 20,
                    }, 100)
                    .to({
                        "x": 460,
                        "y": 450,
                        "width": 20,
                        "height": 20,
                    }, 100)
                    .to({
                        "x": 450,
                        "y": 440,
                        "width": 20,
                        "height": 20,
                    }, 90)
                    .to({
                        "x": 450,
                        "y": 450,
                        "width": 20,
                        "height": 20,
                    }, 90);
                this.ondatas(3);
            }
        } else if (probability == 1) {
            if (shoot_code == 1) {//判读0或者1 不同方向left ---- right  接到球
                // console.log("动画3---右手顶球");
                if (fly == 0) {
                    // console.log("飞右边")
                    flyto = 640;
                } else {
                    // console.log("飞左边")
                    flyto = -30;
                }
                winning = false;
                leftX = 290;  //right
                //球飞出动作
                var tw = egret.Tween.get(ball, { "loop": false }).wait(920).call(function () {
                    object_ontouch.removeChild(goalkeeper);
                    object_ontouch.addChildAt(dingqiu, 3);
                    dingqiu.gotoAndPlay(0, 1);
                }).to({
                    "x": leftX,
                    "y": 325,
                    "width": 20,
                    "height": 20,
                }, 800).to({
                    "x": flyto,
                    "y": 30,
                    "width": 15,
                    "height": 15
                }, 500);
                this.ondatas(2);
            } else {   //未接到球
                // console.log("动画4--------跳起接空");
                winning = true;
                leftX = 330;//left
                //移除静态守门员
                //球飞出动作
                var tw = egret.Tween.get(ball, { "loop": false }).wait(920).call(function () {
                    object_ontouch.removeChild(goalkeeper);
                    object_ontouch.addChild(pukong_actives)
                    pukong_actives.gotoAndPlay(0, 1);
                }).to({
                    "x": leftX,
                    "y": 330,
                    "width": 20,
                    "height": 20,
                }, 500)
                    .wait(100)
                    .to({
                        "x": 330,
                        "y": 350,
                        "width": 20,
                        "height": 20
                    }, 150)
                    .to({
                        "x": 320,
                        "y": 410,
                        "width": 20,
                        "height": 20
                    }, 120)
                    .to({
                        "x": 320,
                        "y": 450,
                        "width": 20,
                        "height": 20,
                    }, 120)
                    .to({
                        "x": 310,
                        "y": 420,
                        "width": 20,
                        "height": 20,
                    }, 100)
                    .to({
                        "x": 310,
                        "y": 450,
                        "width": 20,
                        "height": 20,
                    }, 100)
                    .to({
                        "x": 300,
                        "y": 440,
                        "width": 20,
                        "height": 20,
                    }, 90)
                    .to({
                        "x": 300,
                        "y": 450,
                        "width": 20,
                        "height": 20,
                    }, 90);
                this.ondatas(0);
            }
        } else if (probability == 2) {
            if (shoot_code == 1) {//判读0或者1 不同方向left ---- right  接到球
                // console.log("动画5---------左边翻滚接中球");
                winning = false;
                leftX = 120;  //right
                //球飞出动作
                var tw = egret.Tween.get(ball, { "loop": false }).wait(920).call(function () {
                    object_ontouch.removeChild(goalkeeper);
                    object_ontouch.addChild(zuopuzhong_actives);
                    zuopuzhong_actives.gotoAndPlay(0, 1);
                }).to({
                    "x": leftX,
                    "y": 435,
                    "width": 20,
                    "height": 20,
                }, 700).wait(100).to({
                    "x": leftX,
                    "y": 735,
                    "width": 0,
                    "height": 0
                }, 1);
                this.ondatas(4);
                // this.ondatas(3);
            } else {   //未接到球
                // console.log("动画6-------------左边扑空");
                winning = true;
                leftX = 100;//left
                //移除静态守门员
                //球飞出动作
                var tw = egret.Tween.get(ball, { "loop": false }).wait(920).call(function () {
                    object_ontouch.removeChild(goalkeeper);
                    object_ontouch.addChild(zuoshi_actives)
                    zuoshi_actives.gotoAndPlay(0, 1);
                }).to({
                    "x": leftX,
                    "y": 350,
                    "width": 20,
                    "height": 20,
                }, 500)
                    .wait(100)
                    .to({
                        "x": 100,
                        "y": 380,
                        "width": 20,
                        "height": 20
                    }, 150)
                    .to({
                        "x": 90,
                        "y": 410,
                        "width": 20,
                        "height": 20
                    }, 120)
                    .to({
                        "x": 90,
                        "y": 450,
                        "width": 20,
                        "height": 20,
                    }, 120)
                    .to({
                        "x": 80,
                        "y": 420,
                        "width": 20,
                        "height": 20,
                    }, 100)
                    .to({
                        "x": 80,
                        "y": 450,
                        "width": 20,
                        "height": 20,
                    }, 100)
                    .to({
                        "x": 70,
                        "y": 440,
                        "width": 20,
                        "height": 20,
                    }, 90)
                    .to({
                        "x": 70,
                        "y": 450,
                        "width": 20,
                        "height": 20,
                    }, 90);
                this.ondatas(5);
            }
        } else if (probability == 3) {
            if (shoot_code == 1) {//判读0或者1 不同方向left ---- right  接到球
                // console.log("动画7---------跳起顶球动作2");
                if (fly == 0) {
                    // console.log("飞右边")
                    flyto = 640;
                } else {
                    // console.log("飞左边")
                    flyto = -30;
                }
                winning = false;
                leftX = 310;  //right

                //球飞出动作
                var tw = egret.Tween.get(ball, { "loop": false }).wait(920).call(function () {
                    object_ontouch.removeChild(goalkeeper);
                    object_ontouch.addChildAt(dingqiu2, 3);
                    dingqiu2.gotoAndPlay(0, 1);
                }).to({
                    "x": leftX,
                    "y": 330,
                    "width": 20,
                    "height": 20,
                }, 900).to({
                    "x": flyto,
                    "y": 30,
                    "width": 15,
                    "height": 15
                }, 500);
                this.ondatas(6);
                // this.ondatas(3);
            } else {   //未接到球
                // console.log("动画8--------跳起扑空动作2");
                winning = true;
                leftX = 280;//left
                //移除静态守门员
                //球飞出动作
                var tw = egret.Tween.get(ball, { "loop": false }).wait(920).call(function () {
                    object_ontouch.removeChild(goalkeeper);
                    object_ontouch.addChild(zhongzuopukong_actives)
                    zhongzuopukong_actives.gotoAndPlay(0, 1);
                }).to({
                    "x": leftX,
                    "y": 330,
                    "width": 20,
                    "height": 20,
                }, 500)
                    .wait(100)
                    .to({
                        "x": 280,
                        "y": 350,
                        "width": 20,
                        "height": 20
                    }, 150)
                    .to({
                        "x": 270,
                        "y": 410,
                        "width": 20,
                        "height": 20
                    }, 120)
                    .to({
                        "x": 270,
                        "y": 450,
                        "width": 20,
                        "height": 20,
                    }, 120)
                    .to({
                        "x": 260,
                        "y": 420,
                        "width": 20,
                        "height": 20,
                    }, 100)
                    .to({
                        "x": 260,
                        "y": 450,
                        "width": 20,
                        "height": 20,
                    }, 100)
                    .to({
                        "x": 250,
                        "y": 440,
                        "width": 20,
                        "height": 20,
                    }, 90)
                    .to({
                        "x": 250,
                        "y": 450,
                        "width": 20,
                        "height": 20,
                    }, 90);
                this.ondatas(7);
            }
        }
    }
    private ondatas(nums: number): void {
        if (nums == 0) {
            var pukong_jsons = RES.getRes("pukong_json");
            var pukong_imgs = RES.getRes("pukong_img");
            var pukong_active = new egret.MovieClipDataFactory(pukong_jsons, pukong_imgs);
            pukong_actives = new egret.MovieClip(pukong_active.generateMovieClipData());
            // this.addChild(actives);
            // actives.gotoAndPlay(0, 1);//第一个参数：从第0帧开始展示 ，第二个参数：重复次数
            //完成动画后执行
            pukong_actives.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                if (winning == true) {
                    winnerchannel = winnsound.play(0, 1);
                    var congratulationss = egret.Tween.get(congratulations).to({
                        "width": 483,
                        "height": 214
                    }, 500).wait(800).to({
                        "width": 0,
                        "height": 0
                    }, 1);
                    num += data;
                } else {
                    num += data;
                }
                var nums_t = Math.floor(num * 100) / 100




                adLabel.x = 65;
                adLabel.y = 15;
                adLabel.fontFamily = "KaiTi";
                adLabel.textFlow = <Array<egret.ITextElement>>[
                    {
                        text: "" + nums_t,
                        style: { "textColor": 0xf06f00, "size": 25, "strokeColor": 0x800000, "stroke": 2, "fontFamily": "楷体" }
                    }
                ];
                this.removeChild(progressBars);
                this.removeChild(needle);
                var congratulations1 = egret.Tween.get(congratulations).to({
                    "width": 0,
                    "height": 0
                }, 1)
                var tws = egret.Tween.get(adLabel, { "loop": false }).to({
                    "scaleX": 1.2,
                    "scaleY": 1.2
                }, 600).wait(100);
                tws.to({
                    "scaleX": 1,
                    "scaleY": 1
                }, 600).call(function () {
                    // egret.Tween.resumeTweens(progressball);//暂停动画
                    ball.width = 60;
                    ball.height = 60;
                    ball.x = 275;
                    ball.y = 750;
                    object_ontouch.addChildAt(goalkeeper, 3);

                    foot_actives.gotoAndStop(1)
                    object_ontouch.removeChild(pukong_actives);
                    clickbtn = true;
                    clickbtns = true;
                    // console.log("动画完成后：" + clickbtn);
                    rechar = true;
                    begins = true;
                    closebtn = true;

                });
                // shootbtn.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this);
                //  shootbtn.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBegin, this);
                //  shootbtn.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEnd, this);
            }, this);

        } else if (nums == 1) {
            // console.log("翻滚")
            //移除静态守门员
            //添加动态守门员
            var datas = RES.getRes("ball_json");
            var s = RES.getRes("ball_img");
            var active = new egret.MovieClipDataFactory(datas, s);
            actives = new egret.MovieClip(active.generateMovieClipData());
            // this.addChild(actives);
            // actives.gotoAndPlay(0, 1);//第一个参数：从第0帧开始展示 ，第二个参数：重复次数
            //完成动画后执行
            actives.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                if (winning == true) {
                    winnerchannel = winnsound.play(0, 1);
                    var congratulationss = egret.Tween.get(congratulations).to({
                        "width": 483,
                        "height": 214
                    }, 500).wait(800).to({
                        "width": 0,
                        "height": 0
                    }, 1);
                    num += data;
                } else {
                    num += data;
                }
                var nums_t = Math.floor(num * 100) / 100
                adLabel.x = 65;
                adLabel.y = 15;
                adLabel.fontFamily = "KaiTi";
                adLabel.textFlow = <Array<egret.ITextElement>>[
                    {
                        text: "" + nums_t,
                        style: { "textColor": 0xf06f00, "size": 25, "strokeColor": 0x800000, "stroke": 2, "fontFamily": "楷体" }
                    }
                ];
                this.removeChild(progressBars);
                this.removeChild(needle);
                var congratulations1 = egret.Tween.get(congratulations).to({
                    "width": 0,
                    "height": 0
                }, 1)
                var tws = egret.Tween.get(adLabel, { "loop": false }).to({
                    "scaleX": 1.2,
                    "scaleY": 1.2
                }, 600).wait(100);
                tws.to({
                    "scaleX": 1,
                    "scaleY": 1
                }, 600).call(function () {
                    // egret.Tween.resumeTweens(progressball);//暂停动画
                    ball.width = 60;
                    ball.height = 60;
                    ball.x = 275;
                    ball.y = 750;
                    object_ontouch.addChildAt(goalkeeper, 3);
                    foot_actives.gotoAndStop(1);
                    object_ontouch.removeChild(actives);
                    clickbtn = true;
                    clickbtns = true;
                    // console.log("动画完成后：" + clickbtn);
                    rechar = true;
                    begins = true;
                    closebtn = true;

                });
                // shootbtn.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this);
                //  shootbtn.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBegin, this);
                //  shootbtn.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEnd, this);
            }, this);

        } else if (nums == 2) {
            // console.log("顶球")
            //移除静态守门员
            //添加动态守门员
            var hitBall_jsons = RES.getRes("hitBall_json");
            var hitBall_pngs = RES.getRes("hitBall_png");
            var dingqiu_active = new egret.MovieClipDataFactory(hitBall_jsons, hitBall_pngs);
            dingqiu = new egret.MovieClip(dingqiu_active.generateMovieClipData());
            // this.addChild(dingqiu);
            // this.addChild(actives);
            // actives.gotoAndPlay(0, 1);//第一个参数：从第0帧开始展示 ，第二个参数：重复次数
            //完成动画后执行
            dingqiu.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                if (winning == true) {
                    winnerchannel = winnsound.play(0, 1);
                    var congratulationss = egret.Tween.get(congratulations).to({
                        "width": 483,
                        "height": 214
                    }, 500).wait(800).to({
                        "width": 0,
                        "height": 0
                    }, 1);
                    num += data;
                } else {
                    num += data;
                }
                var nums_t = Math.floor(num * 100) / 100
                adLabel.x = 65;
                adLabel.y = 15;
                adLabel.fontFamily = "KaiTi";
                adLabel.textFlow = <Array<egret.ITextElement>>[
                    {
                        text: "" + nums_t,
                        style: { "textColor": 0xf06f00, "size": 25, "strokeColor": 0x800000, "stroke": 2, "fontFamily": "楷体" }
                    }
                ];
                this.removeChild(progressBars);
                this.removeChild(needle);
                var congratulations1 = egret.Tween.get(congratulations).to({
                    "width": 0,
                    "height": 0
                }, 1)
                var tws = egret.Tween.get(adLabel, { "loop": false }).to({
                    "scaleX": 1.2,
                    "scaleY": 1.2
                }, 600).wait(100);
                tws.to({
                    "scaleX": 1,
                    "scaleY": 1
                }, 600).call(function () {
                    // egret.Tween.resumeTweens(progressball);//暂停动画
                    ball.width = 60;
                    ball.height = 60;
                    ball.x = 275;
                    ball.y = 750;
                    object_ontouch.addChildAt(goalkeeper, 3);
                    foot_actives.gotoAndStop(1);
                    object_ontouch.removeChild(dingqiu);
                    clickbtn = true;
                    clickbtns = true;
                    // console.log("动画完成后：" + clickbtn);
                    rechar = true;
                    begins = true;
                    closebtn = true;
                });
                // shootbtn.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this);
                // shootbtn.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBegin, this);
                // shootbtn.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEnd, this);
            }, this);

        } else if (nums == 3) {
            // console.log("右边失球")
            //移除静态守门员
            //添加动态守门员
            var youshi_jsons = RES.getRes("youshi_json");
            var youshi_pngs = RES.getRes("youshi_png");
            var youshi_active = new egret.MovieClipDataFactory(youshi_jsons, youshi_pngs);
            youshi_actives = new egret.MovieClip(youshi_active.generateMovieClipData());
            // this.addChild(dingqiu);
            // this.addChild(actives);
            // actives.gotoAndPlay(0, 1);//第一个参数：从第0帧开始展示 ，第二个参数：重复次数
            //完成动画后执行
            youshi_actives.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                if (winning == true) {
                    winnerchannel = winnsound.play(0, 1);
                    var congratulationss = egret.Tween.get(congratulations).to({
                        "width": 483,
                        "height": 214
                    }, 500).wait(800).to({
                        "width": 0,
                        "height": 0
                    }, 1);
                    num += data;
                } else {
                    num += data;
                }
                var nums_t = Math.floor(num * 100) / 100
                adLabel.x = 65;
                adLabel.y = 15;
                adLabel.fontFamily = "KaiTi";
                adLabel.textFlow = <Array<egret.ITextElement>>[
                    {
                        text: "" + nums_t,
                        style: { "textColor": 0xf06f00, "size": 25, "strokeColor": 0x800000, "stroke": 2, "fontFamily": "楷体" }
                    }
                ];
                this.removeChild(progressBars);
                this.removeChild(needle);
                var congratulations1 = egret.Tween.get(congratulations).to({
                    "width": 0,
                    "height": 0
                }, 1)
                var tws = egret.Tween.get(adLabel, { "loop": false }).to({
                    "scaleX": 1.2,
                    "scaleY": 1.2
                }, 600).wait(100);
                tws.to({
                    "scaleX": 1,
                    "scaleY": 1
                }, 600).call(function () {
                    // egret.Tween.resumeTweens(progressball);//暂停动画
                    ball.width = 60;
                    ball.height = 60;
                    ball.x = 275;
                    ball.y = 750;
                    object_ontouch.addChildAt(goalkeeper, 3);
                    foot_actives.gotoAndStop(1);
                    object_ontouch.removeChild(youshi_actives);
                    clickbtn = true;
                    clickbtns = true;
                    // console.log("动画完成后：" + clickbtn);
                    rechar = true;
                    begins = true;
                    closebtn = true;
                });
            }, this);

        } else if (nums == 4) {
            // console.log("右边失球")
            //移除静态守门员
            //添加动态守门员
            var zuopuzhong_jsons = RES.getRes("zuopuzhong_json");
            var zuopuzhong_pngs = RES.getRes("zuopuzhong_png");
            var zuopuzhong_active = new egret.MovieClipDataFactory(zuopuzhong_jsons, zuopuzhong_pngs);
            zuopuzhong_actives = new egret.MovieClip(zuopuzhong_active.generateMovieClipData());
            // this.addChild(dingqiu);
            // this.addChild(actives);
            // actives.gotoAndPlay(0, 1);//第一个参数：从第0帧开始展示 ，第二个参数：重复次数
            //完成动画后执行
            zuopuzhong_actives.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                if (winning == true) {
                    winnerchannel = winnsound.play(0, 1);
                    var congratulationss = egret.Tween.get(congratulations).to({
                        "width": 483,
                        "height": 214
                    }, 500).wait(800).to({
                        "width": 0,
                        "height": 0
                    }, 1);
                    num += data;
                } else {
                    num += data;
                }
                var nums_t = Math.floor(num * 100) / 100
                adLabel.x = 65;
                adLabel.y = 15;
                adLabel.fontFamily = "KaiTi";
                adLabel.textFlow = <Array<egret.ITextElement>>[
                    {
                        text: "" + nums_t,
                        style: { "textColor": 0xf06f00, "size": 25, "strokeColor": 0x800000, "stroke": 2, "fontFamily": "楷体" }
                    }
                ];
                this.removeChild(progressBars);
                this.removeChild(needle);
                var congratulations1 = egret.Tween.get(congratulations).to({
                    "width": 0,
                    "height": 0
                }, 1)
                var tws = egret.Tween.get(adLabel, { "loop": false }).to({
                    "scaleX": 1.2,
                    "scaleY": 1.2
                }, 600).wait(100);
                tws.to({
                    "scaleX": 1,
                    "scaleY": 1
                }, 600).call(function () {
                    // egret.Tween.resumeTweens(progressball);//暂停动画
                    ball.width = 60;
                    ball.height = 60;
                    ball.x = 275;
                    ball.y = 750;
                    object_ontouch.addChildAt(goalkeeper, 3);
                    foot_actives.gotoAndStop(1);
                    object_ontouch.removeChild(zuopuzhong_actives);
                    clickbtn = true;
                    clickbtns = true;
                    // console.log("动画完成后：" + clickbtn);
                    rechar = true;
                    begins = true;
                    closebtn = true;
                });
            }, this);

        } else if (nums == 5) {
            // console.log("右边失球")
            //移除静态守门员
            //添加动态守门员
            var zuoshi_jsons = RES.getRes("zuopukong_json");
            var zuoshi_pngs = RES.getRes("zuopukong_png");
            var zuoshi_active = new egret.MovieClipDataFactory(zuoshi_jsons, zuoshi_pngs);
            zuoshi_actives = new egret.MovieClip(zuoshi_active.generateMovieClipData());
            // this.addChild(dingqiu);
            // this.addChild(actives);
            // actives.gotoAndPlay(0, 1);//第一个参数：从第0帧开始展示 ，第二个参数：重复次数
            //完成动画后执行
            zuoshi_actives.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                if (winning == true) {
                    winnerchannel = winnsound.play(0, 1);
                    var congratulationss = egret.Tween.get(congratulations).to({
                        "width": 483,
                        "height": 214
                    }, 500).wait(800).to({
                        "width": 0,
                        "height": 0
                    }, 1);
                    num += data;
                } else {
                    num += data;
                }
                var nums_t = Math.floor(num * 100) / 100
                adLabel.x = 65;
                adLabel.y = 15;
                adLabel.fontFamily = "KaiTi";
                adLabel.textFlow = <Array<egret.ITextElement>>[
                    {
                        text: "" + nums_t,
                        style: { "textColor": 0xf06f00, "size": 25, "strokeColor": 0x800000, "stroke": 2, "fontFamily": "楷体" }
                    }
                ];
                this.removeChild(progressBars);
                this.removeChild(needle);
                var congratulations1 = egret.Tween.get(congratulations).to({
                    "width": 0,
                    "height": 0
                }, 1)
                var tws = egret.Tween.get(adLabel, { "loop": false }).to({
                    "scaleX": 1.2,
                    "scaleY": 1.2
                }, 600).wait(100);
                tws.to({
                    "scaleX": 1,
                    "scaleY": 1
                }, 600).call(function () {
                    // egret.Tween.resumeTweens(progressball);//暂停动画
                    ball.width = 60;
                    ball.height = 60;
                    ball.x = 275;
                    ball.y = 750;
                    object_ontouch.addChildAt(goalkeeper, 3);
                    foot_actives.gotoAndStop(1);
                    object_ontouch.removeChild(zuoshi_actives);
                    clickbtn = true;
                    clickbtns = true;
                    // console.log("动画完成后：" + clickbtn);
                    rechar = true;
                    begins = true;
                    closebtn = true;
                });
            }, this);

        } else if (nums == 6) {
            // console.log("右边失球")
            //移除静态守门员
            //添加动态守门员
            var dingqiu2_jsons = RES.getRes("dingqiu2_json");
            var dingqiu2_pngs = RES.getRes("dingqiu2_png");
            var dingqiu2_active = new egret.MovieClipDataFactory(dingqiu2_jsons, dingqiu2_pngs);
            dingqiu2 = new egret.MovieClip(dingqiu2_active.generateMovieClipData());
            // this.addChild(dingqiu);
            // this.addChild(actives);
            // actives.gotoAndPlay(0, 1);//第一个参数：从第0帧开始展示 ，第二个参数：重复次数
            //完成动画后执行
            dingqiu2.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                if (winning == true) {
                    winnerchannel = winnsound.play(0, 1);
                    var congratulationss = egret.Tween.get(congratulations).to({
                        "width": 483,
                        "height": 214
                    }, 500).wait(800).to({
                        "width": 0,
                        "height": 0
                    }, 1);
                    num += data;
                } else {
                    num += data;
                }
                var nums_t = Math.floor(num * 100) / 100
                adLabel.x = 65;
                adLabel.y = 15;
                adLabel.fontFamily = "KaiTi";
                adLabel.textFlow = <Array<egret.ITextElement>>[
                    {
                        text: "" + nums_t,
                        style: { "textColor": 0xf06f00, "size": 25, "strokeColor": 0x800000, "stroke": 2, "fontFamily": "楷体" }
                    }
                ];
                this.removeChild(progressBars);
                this.removeChild(needle);
                var congratulations1 = egret.Tween.get(congratulations).to({
                    "width": 0,
                    "height": 0
                }, 1)
                var tws = egret.Tween.get(adLabel, { "loop": false }).to({
                    "scaleX": 1.2,
                    "scaleY": 1.2
                }, 600).wait(100);
                tws.to({
                    "scaleX": 1,
                    "scaleY": 1
                }, 600).call(function () {
                    // egret.Tween.resumeTweens(progressball);//暂停动画
                    ball.width = 60;
                    ball.height = 60;
                    ball.x = 275;
                    ball.y = 750;
                    object_ontouch.addChildAt(goalkeeper, 3);
                    foot_actives.gotoAndStop(1);
                    object_ontouch.removeChild(dingqiu2);
                    clickbtn = true;
                    clickbtns = true;
                    // console.log("动画完成后：" + clickbtn);
                    rechar = true;
                    begins = true;
                    closebtn = true;
                });
            }, this);

        } else if (nums == 7) {
            // console.log("右边失球")
            //移除静态守门员
            //添加动态守门员
            var zhongzuoshiqiu_jsons = RES.getRes("zhongzuoshiqiu_json");
            var zhongzuoshiqiu_pngs = RES.getRes("zhongzuoshiqiu_png");
            var zhongzuopukong_active = new egret.MovieClipDataFactory(zhongzuoshiqiu_jsons, zhongzuoshiqiu_pngs);
            zhongzuopukong_actives = new egret.MovieClip(zhongzuopukong_active.generateMovieClipData());
            // this.addChild(dingqiu);
            // this.addChild(actives);
            // actives.gotoAndPlay(0, 1);//第一个参数：从第0帧开始展示 ，第二个参数：重复次数
            //完成动画后执行
            zhongzuopukong_actives.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                if (winning == true) {
                    winnerchannel = winnsound.play(0, 1);
                    var congratulationss = egret.Tween.get(congratulations).to({
                        "width": 483,
                        "height": 214
                    }, 500).wait(800).to({
                        "width": 0,
                        "height": 0
                    }, 1);
                    num += data;
                } else {
                    num += data;
                }
                var nums_t = Math.floor(num * 100) / 100
                adLabel.x = 65;
                adLabel.y = 15;
                adLabel.fontFamily = "KaiTi";
                adLabel.textFlow = <Array<egret.ITextElement>>[
                    {
                        text: "" + nums_t,
                        style: { "textColor": 0xf06f00, "size": 25, "strokeColor": 0x800000, "stroke": 2, "fontFamily": "楷体" }
                    }
                ];
                this.removeChild(progressBars);
                this.removeChild(needle);
                var congratulations1 = egret.Tween.get(congratulations).to({
                    "width": 0,
                    "height": 0
                }, 1)
                var tws = egret.Tween.get(adLabel, { "loop": false }).to({
                    "scaleX": 1.2,
                    "scaleY": 1.2
                }, 600).wait(100);
                tws.to({
                    "scaleX": 1,
                    "scaleY": 1
                }, 600).call(function () {
                    // egret.Tween.resumeTweens(progressball);//暂停动画
                    ball.width = 60;
                    ball.height = 60;
                    ball.x = 275;
                    ball.y = 750;
                    object_ontouch.addChildAt(goalkeeper, 3);
                    foot_actives.gotoAndStop(1);
                    object_ontouch.removeChild(zhongzuopukong_actives);
                    clickbtn = true;
                    clickbtns = true;
                    // console.log("动画完成后：" + clickbtn);
                    rechar = true;
                    begins = true;
                    closebtn = true;
                });
            }, this);

        }
    }

    /**
     * 充值5元
     * @param event
     */
    private onTouchrecharge1(event: TouchEvent) {
        // if (cannotbtn == false){
        //     return
        // }
        clickschannel = clickssound.play(0, 1);



        if (closebtn == false) {
            return;
        }
        if(lucklylock == false){
            return
        }
        checknum = 1;
        moneyselect = 1;
        recharge1.texture = RES.getRes("5check_png");
        recharge1.x = 30;
        recharge1.y = 800;
        recharge1.width = 50;
        recharge1.height = 50;
        recharge2.texture = RES.getRes("10_png");
        recharge2.x = 80;
        recharge2.y = 720;
        recharge2.width = 60;
        recharge2.height = 60;
        recharge3.texture = RES.getRes("50_png");
        recharge3.x = 30;
        recharge3.y = 640;
        recharge3.width = 70;
        recharge3.height = 70;
        // object_ontouch.addChildAt(recharge1, 4);
        // object_ontouch.addChildAt(recharge2, 4);
        // object_ontouch.addChildAt(recharge3, 4);
    }

    /**
     * 充值10元
     * @param event
     */
    private onTouchrecharge2(event: TouchEvent) {
        // if (cannotbtn == false){
        //     return
        // }
        clickschannel = clickssound.play(0, 1);
        if (closebtn == false) {
            return;
        }
        if(lucklylock == false){
            return
        }
        checknum = 10;
        moneyselect = 2;
        recharge1.texture = RES.getRes("5_png");
        recharge1.x = 30;
        recharge1.y = 800;
        recharge1.width = 50;
        recharge1.height = 50;
        recharge2.texture = RES.getRes("10check_png");
        recharge2.x = 80;
        recharge2.y = 720;
        recharge2.width = 60;
        recharge2.height = 60;
        recharge3.texture = RES.getRes("50_png");
        recharge3.x = 30;
        recharge3.y = 640;
        recharge3.width = 70;
        recharge3.height = 70;
        // object_ontouch.addChildAt(recharge1, 4);
        // object_ontouch.addChildAt(recharge2, 4);
        // object_ontouch.addChildAt(recharge3, 4);
    }

    /**
     * 充值50元
     * @param event
     */
    private onTouchrecharge3(event: TouchEvent) {
        // if (cannotbtn == false){
        //     return
        // }
        clickschannel = clickssound.play(0, 1);
        if (closebtn == false) {
            return;
        }
        if(lucklylock == false){
            return
        }
        checknum = 50;
        moneyselect = 3;
        recharge1.texture = RES.getRes("5_png");
        recharge1.x = 30;
        recharge1.y = 800;
        recharge1.width = 50;
        recharge1.height = 50;
        recharge2.texture = RES.getRes("10_png");
        recharge2.x = 80;
        recharge2.y = 720;
        recharge2.width = 60;
        recharge2.height = 60;
        recharge3.texture = RES.getRes("50check_png");
        recharge3.x = 30;
        recharge3.y = 640;
        recharge3.width = 70;
        recharge3.height = 70;
        // object_ontouch.addChildAt(recharge1, 4);
        // object_ontouch.addChildAt(recharge2, 4);
        // object_ontouch.addChildAt(recharge3, 4);
    }

    //邮箱
    private messagetouch(event: TouchEvent) {
        // if (cannotbtn == false){
        //     return
        // }
        if (closebtn == false) {
            return
        }
        if(lucklylock == false){
            return
        }
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/foot/user/getUserOpenId", egret.HttpMethod.GET);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.onGetMsg2, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
        //显示对象容器，使用DisplayObjectContainer
        // var container = new egret.DisplayObjectContainer();
        //容器的缩放，旋转，位移将影响到它下面的子节点(即包含的显示对象)
        var myScroller = new eui.Scroller();
        container.width = 400;
        container.height = 711;
        container.x = 120;
        container.y = 150;
        container.name = "邮箱"
        solcontainer.x = 15;
        solcontainer.y = 0;
        solcontainer.width = 335;
        solcontainer.height = msgheight;
        // var group = new eui.Group();
        // var img = new eui.Image("resource/rechargeBg.jpg");
        // group.addChild(img);
        //创建一个Scroller
        myscrollView.setContent(solcontainer);
        myscrollView.x = 25;
        myscrollView.y = 130;
        myscrollView.width = 350;
        myscrollView.height = 500;

        // container.addChildAt(solcontainer,999);
        // title.width = 250;
        // title.x = 310;
        // title.y = 135;
        // title.textFlow = <Array<egret.ITextElement>>[
        //     {
        //         text: "邮箱",
        //         style: { "textColor": 0x000000, "size": 40, "strokeColor": 0x6699cc, "stroke": 2, "fontFamily": "楷体" }
        //     }
        // ];

        var loding_j = RES.getRes("lodingpic_json");
        var loding_i = RES.getRes("lodingpic_png");
        var loding_active = new egret.MovieClipDataFactory(loding_j, loding_i);
        loding_actives = new egret.MovieClip(loding_active.generateMovieClipData());
        loding_actives.gotoAndPlay(0, -1);
        loding_actives.x = -160;
        loding_actives.y = -100;

        closebtn = false;
        onexplainwindows2.texture = RES.getRes("mailboxwindows_png");
        onexplainwindows2.width = 400;
        onexplainwindows2.height = 711;

        var closebtns: egret.Bitmap = new Bitmap();
        closebtns.texture = RES.getRes("close");
        closebtns.width = 50;
        closebtns.height = 50;
        closebtns.x = 355;
        closebtns.y = -5;
        closebtns.touchEnabled = true;
        clickreceives = false;

        container.addChild(onexplainwindows2);
        container.addChild(loding_actives);
        container.addChild(myscrollView);
        container.addChild(closebtns);
        // container.addChild(title);
        this.addChild(container);

        mssage_num = this;
        closebtns.addEventListener(egret.TouchEvent.TOUCH_TAP, this.closebtn2, this);

    }


    private onGetMsg2(event: egret.Event): void {
        var request = <egret.HttpRequest>event.currentTarget;
        var req = JSON.parse(request.response);//转为JSON格式
        container.removeChild(loding_actives);
        solcontainer.removeChildren();
        console.log("返回数据" + req.data.giveMoneyList);
        if (req.data.giveMoneyList.length != 0) {
            messageList = req.data.giveMoneyList;
            msglength = req.data.giveMoneyList.length;//获取长度
            msgheight = msglength * 110;
            for (let i = 0; i < msglength; i++) {//行
                var timestamp3 = messageList[i].giveTime / 1000;
                var newDate = new Date();
                newDate.setTime(timestamp3 * 1000);
                var textList: egret.TextField = new egret.TextField();
                textList.width = 320;
                // textList.width = 560;
                textList.x = 20;
                textList.y = 0 + (i * 110);
                textList.textFlow = <Array<egret.ITextElement>>[
                    {
                        text: "" + messageList[i].giveType,
                        style: { "textColor": 0xFFFFFF, "size": 30, "fontFamily": "楷体" }
                    }, {
                        text: "\n时间：" + newDate.toLocaleString(),
                        style: { "textColor": 0xFFFFFF, "size": 20, "fontFamily": "楷体" }
                    }, {
                        text: "\n金额：" + messageList[i].gitMoney,
                        style: { "textColor": 0xFFFFFF, "size": 20, "fontFamily": "楷体" }
                    }
                ];
                var data = messageList[i].gitMoney;
                var msgid = messageList[i].id;
                var receives: egret.Bitmap = new Bitmap();
                receives.name = "?gitMoney=" + data + "&id=" + msgid;
                receives.texture = RES.getRes("receive");
                receives.width = 100;
                receives.height = 31;
                receives.x = 220;
                receives.y = 60 + (i * 110);
                // receives.bitmapData = "?gitMoney="+messageList[i].gitMoney+"&id="+msgid;
                receives.touchEnabled = true;
                clickreceives = true;
                receives.addEventListener(egret.TouchEvent.TOUCH_TAP, this.receivesOnTouch, this);
                solcontainer.addChildAt(textList, 99);
                solcontainer.addChildAt(receives, 99);
            }
        } else {
            // msglength = 0;//获取长度
            var tiptext: egret.TextField = new egret.TextField();
            tiptext.x = 60;
            tiptext.y = 200;
            tiptext.width = 320;
            tiptext.textFlow = <Array<egret.ITextElement>>[
                {
                    text: "邮箱空空如也！",
                    style: { "textColor": 0xFFFFFF, "size": 30, "fontFamily": "楷体" }
                }
            ];
            // if (solcontainer.parent) {
            //     solcontainer.removeChild(textList);
            //     solcontainer.removeChild(receives);
            // }
            // solcontainer.removeChildren();
            solcontainer.addChildAt(tiptext, 99);
            // return;
        }
    }
    private receivesOnTouch(evt: egret.Event): void {
        if (clickreceives == false) {
            return;
        }
        var currentTarget: any = evt.currentTarget;
        currentTarget.texture = ""
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/foot/user/setGitMoney" + currentTarget.name, egret.HttpMethod.POST);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.getMsg, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
    }
    private getMsg(event: egret.Event): void {
        var requests = <egret.HttpRequest>event.currentTarget;
        var req = JSON.parse(requests.response);//转为JSON格式
        // console.log(req);
        if (req.error_code == 0) {
            this.addtips(req.data, "不刷新");
            // alert(req.data)
        } else {
            this.addtips("领取失败", "刷新");
            // alert("领取失败");
        }
    }

    //玩法说明
    private onTouchercatalog(event: egret.TouchEvent) {
        // if (cannotbtn == false){
        //     return
        // }
        if (closebtn == false) {
            return
        }
        if(lucklylock == false){
            return
        }
        // title.width = 250;
        // title.x = 230;
        // title.y = 220;
        // title.textFlow = <Array<egret.ITextElement>>[
        //     {
        //         text: "游戏玩法",
        //         style: { "textColor": 0x000000, "size": 40, "strokeColor": 0x6699cc, "stroke": 2, "fontFamily": "楷体" }
        //     }
        // ];
        closebtn = false;
        playcontainer.width = 400;
        playcontainer.height = 711;
        playcontainer.x = 120;
        playcontainer.y = 150;
        playcontainer.name = "游戏说明"

        playsolcontainer.x = 0;
        playsolcontainer.y = 0;
        playsolcontainer.width = 335;
        playsolcontainer.height = 1500;
        var myScroller = new eui.Scroller();
        myscrollView.setContent(playsolcontainer);
        myscrollView.x = 25;
        myscrollView.y = 130;
        myscrollView.width = 350;
        myscrollView.height = 500;
        var playonexplainwindows: egret.Bitmap = new Bitmap();
        playonexplainwindows.texture = RES.getRes("playwindow_png");
        playonexplainwindows.width = 400;
        playonexplainwindows.height = 711;
        // onexplainwindows.x = -25;
        // onexplainwindows.y = 80;
        var playclosebtn: egret.Bitmap = new Bitmap();
        playclosebtn.texture = RES.getRes("close");
        playclosebtn.width = 50;
        playclosebtn.height = 50;
        playclosebtn.x = 355;
        playclosebtn.y = -5;
        playclosebtn.touchEnabled = true;
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/foot/user/getSystemSetting", egret.HttpMethod.GET);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.getSystemSetting, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
        playclosebtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.playclosebtn, this);

        this.addChildAt(playcontainer, 98);
        playcontainer.addChildAt(playonexplainwindows, 8)
        playcontainer.addChildAt(myscrollView, 9)
        playcontainer.addChildAt(playclosebtn, 9)
        // playcontainer.addChildAt(title, 8)
        // this.addChildAt(cbtn, 100);
        // this.addChild(title);
    }

    private getSystemSetting(event: egret.Event): void {
        var requests = <egret.HttpRequest>event.currentTarget;
        var req = JSON.parse(requests.response);//转为JSON格式
        // console.log(req);
        // ID值(text)
        text1.width = 250;
        text1.x = 60;
        text1.y = 20;
        text1.textFlow = <Array<egret.ITextElement>>[
            {
                text: "" + req.data.gamePlay,//336699   0x6699cc
                style: { "textColor": 0xFFFFFF, "size": 25, "fontFamily": "楷体" }
            }, {
                text: "" + req.data.kickSkill,//336699   0x6699cc
                style: { "textColor": 0xFFFFFF, "size": 25, "fontFamily": "楷体" }
            }

        ];
        playsolcontainer.addChildAt(text1, 99);
        closebtn = false;
    }

    //点击购买
    public onTouchBuy(event: egret.TouchEvent) {
        // if (cannotbtn == false){
        //     return
        // }
        this.buyMoney();
    }

    private buy(): void { // 5元

        if (cannotbtn == false) {
            alert("获取用户信息中，请稍后重试");
            return
        }
        if (btnclose == false) {
            return;
        }
        // window.
        window.location.href = http_weixin + "/footballgame/payment.html?money=1&openId=" + openId;
        // moneys = 500;
        // money_give = 1;
        // this.onTouchBuys();
    }

    private buy10(): void { // 10元

        if (cannotbtn == false) {
            alert("获取用户信息中，请稍后重试");

            return
        }
        if (btnclose == false) {
            return;
        }
        window.location.href = http_weixin + "/footballgame/payment.html?money=2&openId=" + openId;
        // moneys = 1000;
        // money_give = 2;
        // this.onTouchBuys();
    }

    private buy50(): void { // 50元

        if (cannotbtn == false) {
            alert("获取用户信息中，请稍后重试");

            return
        }
        if (btnclose == false) {
            return;
        }
        window.location.href = http_weixin + "/footballgame/payment.html?money=3&openId=" + openId;
        // moneys = 5000;
        // money_give = 5;
        // this.onTouchBuys();
    }

    private buy500(): void { // 500元

        if (cannotbtn == false) {
            alert("获取用户信息中，请稍后重试");

            return
        }
        if (btnclose == false) {
            return;
        }
        window.location.href = http_weixin + "/footballgame/payment.html?money=4&openId=" + openId;
        // moneys = 50000;
        // money_give = 50;
        // this.onTouchBuys();
    }

    private buy1k(): void { // 1K元

        if (cannotbtn == false) {
            alert("获取用户信息中，请稍后重试");

            return
        }
        if (btnclose == false) {
            return;
        }
        window.location.href = http_weixin + "/footballgame/payment.html?money=5&openId=" + openId;
        // moneys = 100000;
        // money_give = 100;
        // this.onTouchBuys();
    }

    private buy2k(): void { // 2K元

        if (cannotbtn == false) {
            alert("获取用户信息中，请稍后重试");

            return
        }
        if (btnclose == false) {
            return;
        }
        window.location.href = http_weixin + "/footballgame/payment.html?money=6&openId=" + openId;
        // moneys = 200000;
        // money_give = 200;
        // this.onTouchBuys();
    }

    // public onTouchBuys(): void {

    //     // console.log(req);
    //     wx.ready(function () {
    //         wx.checkJsApi({
    //             jsApiList: ['chooseWXPay'],
    //             success: function (res) {

    //                 // 以键值对的形式返回，可用的api值true，不可用为false
    //                 var request = new egret.HttpRequest();
    //                 request.responseType = egret.HttpResponseType.TEXT;
    //                 request.open(http_open + "/wechat/shoppay?money=" + moneys, egret.HttpMethod.POST);
    //                 request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    //                 request.send();

    //                 request.addEventListener(egret.Event.COMPLETE, function (event: egret.Event) {
    //                     var request = <egret.HttpRequest>event.currentTarget;
    //                     var res = JSON.parse(request.response);//转为JSON格式
    //                     wx.chooseWXPay({
    //                         appId: res.data.appId,
    //                         timestamp: res.data.timeStamp, // 支付签名时间戳，注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
    //                         nonceStr: res.data.nonceStr, // 支付签名随机串，不长于 32 位
    //                         package: res.data.package, // 统一支付接口返回的prepay_id参数值，提交格式如：prepay_id=***）
    //                         signType: res.data.signType, // 签名方式，默认为'SHA1'，使用新版支付需传入'MD5'
    //                         paySign: res.data.paySign, // 支付签名
    //                         success: function (res) {


    //                             // alert(res.errMsg);
    //                             // 支付成功后的回调函数
    //                             if (res.errMsg == "chooseWXPay:ok") {
    //                                 var money_buy = moneys / 100;
    //                                 var givemoneys = money_give;
    //                                 //支付成功
    //                                 // alert('支付成功');
    //                                 var request = new egret.HttpRequest();
    //                                 // var params = ;
    //                                 request.responseType = egret.HttpResponseType.TEXT;
    //                                 request.open(http_open + "/foot/user/setBalanceMoney?money=" + money_buy + "&gitMoney=" + givemoneys, egret.HttpMethod.POST);
    //                                 request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    //                                 request.send();
    //                                 request.addEventListener(egret.Event.COMPLETE, function (event: egret.Event) {
    //                                     var request = <egret.HttpRequest>event.currentTarget;
    //                                     var res = JSON.parse(request.response);//转为JSON格式
    //                                     if (res.error_code == 0) {
    //                                         alert("支付成功");
    //                                     } else {
    //                                         alert("支付失败");
    //                                     }

    //                                 }, this);
    //                                 request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
    //                                 request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
    //                             } else {
    //                                 alert(res.errMsg);
    //                             }
    //                         },
    //                         cancel: function (res) {
    //                             //支付取消123
    //                             alert('支付取消');
    //                         }
    //                     });
    //                 }, this);
    //                 request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
    //                 request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
    //             }
    //         })

    //     })

    // }
    // private moneyget() {
    //     var request = new egret.HttpRequest();
    //     request.responseType = egret.HttpResponseType.TEXT;
    //     request.open(http_open + "/wechat/shoppay?money=" + 500, egret.HttpMethod.POST);
    //     request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    //     request.send();
    //     request.addEventListener(egret.Event.COMPLETE, this.bysmoney, this);
    //     request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
    //     request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
    // }

    // public bysmoney(event: egret.Event): void {


    private getWeiXinConfig() {
        var index = "/footballgame/index.html";
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/wechat/getweixinjs?url=" + http_weixin + index, egret.HttpMethod.GET);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.onweixin, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
    }
    private onweixin(event: egret.Event): void {
        var request = <egret.HttpRequest>event.currentTarget;
        var req = JSON.parse(request.response);//转为JSON格式
        //配置参数
        var bodyConfig = new BodyConfig();
        bodyConfig.debug = false;// 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        bodyConfig.appId = req.data.appId;// 必填，公众号的唯一标识
        bodyConfig.timestamp = req.data.timestamp;// 必填，生成签名的时间戳
        bodyConfig.nonceStr = req.data.nonceStr;// 必填，生成签名的随机串
        bodyConfig.signature = req.data.signature;// 必填，签名，见附录1
        bodyConfig.jsApiList = [// 必填，需要使用的JS接口列表
            // 所有要调用的 API 都要加到这个列表中
            'chooseWXPay', 'hideMenuItems'
        ];
        wx.config(bodyConfig);
    }

    //公告框
    private skillwindow(): void {
        // if (cannotbtn == false){
        //     return
        // }
        if (closebtn == false) {
            return
        }
        if(lucklylock == false){
            return
        }
        // title.width = 250;
        // title.x = 230;
        // title.y = 220;
        // title.textFlow = <Array<egret.ITextElement>>[
        //     {
        //         text: "游戏公告",
        //         style: { "textColor": 0x000000, "size": 40, "strokeColor": 0x6699cc, "stroke": 2, "fontFamily": "楷体" }
        //     }
        // ];

        closebtn = false;
        Noticecontainer.width = 400;
        Noticecontainer.height = 711;
        Noticecontainer.x = 120;
        Noticecontainer.y = 150;

        Noticesolcontainer.x = 0;
        Noticesolcontainer.y = 0;
        Noticesolcontainer.width = 335;
        Noticesolcontainer.height = 1500;
        var myScroller = new eui.Scroller();
        myscrollView.setContent(Noticesolcontainer);
        myscrollView.x = 25;
        myscrollView.y = 130;
        myscrollView.width = 350;
        myscrollView.height = 500;
        var noticebg: egret.Bitmap = new Bitmap();
        noticebg.texture = RES.getRes("noticewindows_png");
        noticebg.width = 400;
        noticebg.height = 711;
        // noticebg.x = -25;
        // noticebg.y = 80;
        var noticebtn: egret.Bitmap = new Bitmap();
        noticebtn.texture = RES.getRes("close");
        noticebtn.width = 50;
        noticebtn.height = 50;
        noticebtn.x = 355;
        noticebtn.y = -5;
        noticebtn.touchEnabled = true;
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/foot/user/getSystemSetting", egret.HttpMethod.GET);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.updateNotice, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
        noticebtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.noticeclosebtn, this);
        this.addChildAt(Noticecontainer, 98);
        Noticecontainer.addChildAt(noticebg, 8);
        Noticecontainer.addChildAt(myscrollView, 9);
        Noticecontainer.addChildAt(noticebtn, 9);
        // Noticecontainer.addChild(title);
    }

    private updateNotice(event: egret.Event): void {
        var requests = <egret.HttpRequest>event.currentTarget;
        var req = JSON.parse(requests.response);//转为JSON格式
        // console.log(req);
        //ID值(text)
        text1.width = 250;
        text1.x = 50;
        text1.y = 20;
        text1.textFlow = <Array<egret.ITextElement>>[
            {
                text: "" + req.data.updateNotice,//336699   0x6699cc
                style: { "textColor": 0xFFFFFF, "size": 25, "fontFamily": "楷体" }
            }
        ];
        Noticesolcontainer.addChildAt(text1, 99);
        closebtn = false;

    }

    //关闭充值按钮
    private closeRecharge(): void {
        if (btnclose == false) {
            return
        }
        closebtn = true;
        click_msg = true;
        clickbtn = true;
        ontouch = true;
        rechar = true;
        var recharge = egret.Tween.get(catalogTips).to({
            "width": 0,
            "height": 0
        }, 200);
        // ontouch_object.removeChild(buysome);
        ontouch_object.removeChild(buy);
        ontouch_object.removeChild(buy10);
        ontouch_object.removeChild(buy50);
        ontouch_object.removeChild(buy500);
        ontouch_object.removeChild(buy1k);
        ontouch_object.removeChild(buy2k);
        ontouch_object.removeChild(close1);
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/foot/user/getUserOpenId", egret.HttpMethod.GET);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.onGetComplete, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
    }

    //展开选项
    private moreselect(): void {
        // if (cannotbtn == false){
        //     return
        // }
        if (moreclick == false) {
            return;
        }
        if(lucklylock == false){
            return
        }

        if (closebtn == false || btnclose == false) {
            return;
        }
        if (checkmore == true) {

            var buybtn = egret.Tween.get(buyBtn, { "loop": false }).to({
                "y": 160
            }, 300);
            var cataLog = egret.Tween.get(catalog, { "loop": false }).to({
                "y": 240
            }, 300);
            var bulletinBoardbtn = egret.Tween.get(bulletinBoardBtn, { "loop": false }).to({
                "y": 400
            }, 300);
            var explains = egret.Tween.get(explain, { "loop": false }).to({
                "y": 320
            }, 300);

            var redopen = egret.Tween.get(redspot, { "loop": false }).to({
                "y": 495
            }, 300);


            var taskBtnopen = egret.Tween.get(taskBtn, { "loop": false }).to({
                "y": 490
            }, 300);
            checkmore = false;
        } else {
            var buybtn = egret.Tween.get(buyBtn, { "loop": false }).to({
                "y": 80
            }, 300);
            var cataLog = egret.Tween.get(catalog, { "loop": false }).to({
                "y": 80
            }, 300);
            var bulletinBoardbtn = egret.Tween.get(bulletinBoardBtn, { "loop": false }).to({
                "y": 80
            }, 300);
            var explains = egret.Tween.get(explain, { "loop": false }).to({
                "y": 80
            }, 300);
            var redopen = egret.Tween.get(redspot, { "loop": false }).to({
                "y": 80
            }, 300);
            var taskBtnopen = egret.Tween.get(taskBtn, { "loop": false }).to({
                "y": 80
            }, 300);
            checkmore = true;
        }
    }

    //获取版本
    private onexplain(): void {
        // if (cannotbtn == false){
        //     return
        // }
        if (closebtn == false) {
            return
        }
        if(lucklylock == false){
            return
        }
        closebtn = false;
        // onexplaincontainer
        onexplaincontainer.width = 400;
        onexplaincontainer.height = 711;
        onexplaincontainer.x = 120;
        onexplaincontainer.y = 150;
        onexplainsolcontainer.x = 0;
        onexplainsolcontainer.y = 0;
        onexplainsolcontainer.width = 335;
        onexplainsolcontainer.height = 1500;
        var myScroller = new eui.Scroller();
        myscrollView.setContent(onexplainsolcontainer);
        myscrollView.x = 25;
        myscrollView.y = 130;
        myscrollView.width = 350;
        myscrollView.height = 500;
        var versionwindows: egret.Bitmap = new Bitmap();
        versionwindows.texture = RES.getRes("editionwindows_png");
        versionwindows.width = 400;
        versionwindows.height = 711;
        var versionbtn: egret.Bitmap = new Bitmap();
        versionbtn.texture = RES.getRes("close");
        versionbtn.width = 50;
        versionbtn.height = 50;
        versionbtn.x = 355;
        versionbtn.y = -5;
        versionbtn.touchEnabled = true;
        // title.width = 250;
        // title.x = 230;
        // title.y = 220;
        // title.textFlow = <Array<egret.ITextElement>>[
        //     {
        //         text: "当前版本",
        //         style: { "textColor": 0x000000, "size": 40, "strokeColor": 0x6699cc, "stroke": 2, "fontFamily": "楷体" }
        //     }
        // ];
        // http://localhost:8080/foot/manager/ setEditionInfo //获取版本信息
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/foot/user/getEdition", egret.HttpMethod.GET);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.getEditionInfo, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
        versionbtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.versionclosebtn, this);
        this.addChildAt(onexplaincontainer, 98);
        onexplaincontainer.addChildAt(versionwindows, 8);
        onexplaincontainer.addChildAt(myscrollView, 9)
        onexplaincontainer.addChildAt(versionbtn, 9)
        // this.addChildAt(onexplainwindows, 98);
        // this.addChildAt(cbtn, 100);
        // this.addChild(title);
    }

    private getEditionInfo(event: egret.Event): void {
        var request = <egret.HttpRequest>event.currentTarget;
        var req = JSON.parse(request.response);//转为JSON格式
        // console.log(req);
        // console.log(req);
        //ID值(text)
        text1.width = 250;
        text1.x = 70;
        text1.y = 0;
        text1.textFlow = <Array<egret.ITextElement>>[
            {
                text: "更新版本号:" + req.versionContent,//336699   0x6699cc
                style: { "textColor": 0xFFFFFF, "size": 30, "fontFamily": "楷体" }
            }
        ];

        //ID值(text)
        text2.width = 250;
        text2.x = 50;
        text2.y = 50;
        text2.textFlow = <Array<egret.ITextElement>>[
            {
                text: "" + req.versionNum,//336699   0x6699cc
                style: { "textColor": 0xFFFFFF, "size": 25, "fontFamily": "楷体" }
            }
        ];
        onexplainsolcontainer.addChildAt(text1, 99);
        onexplainsolcontainer.addChildAt(text2, 99);
        closebtn = false;
    }
    private onGetMsg(event: egret.Event): void {
        var request = <egret.HttpRequest>event.currentTarget;
        var req = JSON.parse(request.response);//转为JSON格式

        console.log("返回数据" + req.data.giveMoneyList);
        if (req.data.giveMoneyList.length != 0) {
            ontouch_object.addChildAt(red, 19);
            messageList = req.data.giveMoneyList;
            msglength = req.data.giveMoneyList.length;//获取长度
        } else {
            ontouch_object.removeChild(red);
            msglength = 0;//获取长度
        }

    }

    //接口返回数据
    private onGetComplete(event: egret.Event): void {
        var request = <egret.HttpRequest>event.currentTarget;
        var req = JSON.parse(request.response);//转为JSON格式
        // console.log(req);
        openId = req.data.openid;
        console.log(req.data);
        var haveredspot = req.data.missionContent;
        alertText = req.data.alert;
        var settimes = req.data.alert.length * 3000;
        var lengthalert = (alertText.length * 30) * -1;
        console.log(lengthalert);
        var idLabel: egret.TextField = new egret.TextField();//微信名称
        //ID值(text)
        idLabel.x = 135;
        idLabel.y = 70;
        idLabel.textFlow = <Array<egret.ITextElement>>[
            {
                text: "" + req.data.nickName + "",//336699   0x6699cc
                style: { "textColor": 0x000000, "size": 30, "fontFamily": "楷体" }
            }
        ];
        numberOfTurns = req.data.turnCount
        //ID值(text)
        rotationTimes.x = 315;
        rotationTimes.y = 150;
        rotationTimes.textFlow = <Array<egret.ITextElement>>[
            {
                text: "抽奖次数(" + req.data.turnCount + ")",//336699   0x6699cc
                style: { "textColor": 0x000000, "size": 20, "fontFamily": "楷体" }
            }
        ];
        rTimes = req.data.turnCount;


        // haveredspot = 0;
        if (haveredspot == 0) {
            redspot.visible = false;
        } else {
            redspot.visible = true;
        }

        spr.graphics.beginFill(0x000000);
        spr.alpha = 0.3;
        spr.graphics.drawRect(0, 0, 640, 40);
        spr.graphics.endFill();
        spr.y = 210;
        spr.name = "大的"
        sprs.graphics.drawRect(0, 0, 640, 40);
        sprs.graphics.endFill();
        sprs.x = 640;
        sprs.name = "下一级"
        bulletinBoard.alpha = 10;
        bulletinBoard.x = 0;
        bulletinBoard.y = 10;
        bulletinBoard.fontFamily = "KaiTi";
        bulletinBoard.textFlow = <Array<egret.ITextElement>>[
            {
                text: alertText,
                style: { "textColor": 0xFFFFFF, "size": 20, "fontFamily": "楷体" }
            }
        ];

        bulletinBoards = egret.Tween.get(sprs, { "loop": true });
        bulletinBoards.to({
            "x": lengthalert
        }, settimes);
        bulletinBoard.name = "文字区域"
        var labas: egret.Bitmap = new Bitmap();
        labas.texture = RES.getRes("laba_png");
        labas.x = -40;
        labas.y = 5;
        labas.alpha = 10;
        labas.name = "喇叭图标"
        this.addChildAt(spr, 20);
        spr.addChildAt(sprs, 20);
        sprs.addChildAt(bulletinBoard, 20);
        sprs.addChildAt(labas, 20);


        //游戏金(text)
        num = req.data.balanceMoney;
        var nums_t = Math.floor(num * 100) / 100
        // alert(nums_t);
        adLabel.x = 65;
        adLabel.y = 15;
        adLabel.fontFamily = "KaiTi";
        adLabel.textFlow = <Array<egret.ITextElement>>[
            {
                text: "" + nums_t,
                style: { "textColor": 0xf06f00, "size": 25, "strokeColor": 0x800000, "stroke": 2, "fontFamily": "楷体" }
            }
        ];

        if (req.data.giveMoneyList.length != 0) {
            ontouch_object.addChildAt(red, 19);
            messageList = req.data.giveMoneyList;
        }
        // openId = req.data.openid;
        balanceMoney = req.data.balanceMoney;

        this.addChildAt(idLabel, 21);
        this.addChildAt(rotationTimes, 21);
        goalcontainer.addChildAt(adLabel, 1);
        // addBox.touchEnabled = true ; 

        msglength = req.data.giveMoneyList.length;//获取长度
        msgheight = msglength * 110;
        imgUrl = req.data.headimgurl;
        RES.getResByUrl("" + imgUrl, this.onComplete, this, RES.ResourceItem.TYPE_IMAGE);
        cannotbtn = true;

    }

    private onGetIOError(event: egret.IOErrorEvent): void {
        console.log("get error : " + event);
    }

    private onGetProgress(event: egret.ProgressEvent): void {
        console.log("get progress : " + Math.floor(100 * event.bytesLoaded / event.bytesTotal) + "%");
    }

    //填充头像
    private onComplete(event: any): void {
        var img: egret.Texture = <egret.Texture>event;
        var head: egret.Bitmap = new egret.Bitmap(img);
        head.width = 90;
        head.height = 90;
        head.x = 20;
        head.y = 55;
        var circle: egret.Shape = new egret.Shape();
        // circle.graphics.beginFill(0x0000ff);
        circle.graphics.beginFill(0xFFFF00);
        circle.graphics.drawCircle(65, 101, 44);
        circle.graphics.endFill();
        // this.addChild(circle);
        head.mask = circle;

        head.touchEnabled = true;
        this.addChildAt(head, 21);
        this.addChildAt(circle, 22);
        head.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchToMy, this)

    }
    private onTouchToMy(): void {
        if (closebtn == false) {
            return
        }
        if(lucklylock == false){
            return
        }
        window.location.href = "/income.html";
    }
    //底部菜单跳转按钮
    private btn2(): void {
        // if (cannotbtn == false){
        //     return
        // }

        if (closebtn == false) {
            return
        }
        if(lucklylock == false){
            return
        }

        // foot/advert/checkLookAdvert
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/foot/advert/checkLookAdvert", egret.HttpMethod.GET);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.checkad, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);



    }
    private checkad(event: egret.Event): void {
        var request = <egret.HttpRequest>event.currentTarget;
        var req = JSON.parse(request.response);//转为JSON格式
        console.log(req);
        if (req.error_code == 0) {
            window.location.href = "/release.html";
        } else {
            this.addtips(req.data, "s不刷新");
        }
    }





    private btn3(): void {
        // if (cannotbtn == false){
        //     return
        // }
        if (closebtn == false) {
            return
        }
        if(lucklylock == false){
            return
        }
        window.location.href = "/QR-code.html";
    }
    // private btn4():void {  //客服
    //     if (closebtn == false) {
    //         return
    //     }
    //     window.location.href = "/service.html";
    // }
    private btn5(): void {
        // if (cannotbtn == false){
        //     return
        // }
        if (closebtn == false) {
            return
        }
        if(lucklylock == false){
            return
        }
        window.location.href = "/income.html";
    }

    // 游戏玩法页面关闭按钮
    private playclosebtn(): void {
        if (btnclose == false) {
            return;
        }
        moreclick = true;
        // alert("关闭游戏说明页面");
        closebtn = true;
        ontouch_object.removeChild(playcontainer);
    }

    private versionclosebtn(): void {
        if (btnclose == false) {
            return;
        }
        // alert("关闭当前版本页面");
        closebtn = true;
        ontouch_object.removeChild(onexplaincontainer);
    }
    // 
    private noticeclosebtn(): void {
        if (btnclose == false) {
            return;
        }
        // alert("关闭游戏公告页面");
        closebtn = true;
        ontouch_object.removeChild(Noticecontainer);
    }
    //关闭按钮事件
    private closebtn(): void {
        if (btnclose == false) {
            return;
        }
        closebtn = true;
        ontouch_object.removeChild(onexplainwindows);
        ontouch_object.removeChild(cbtn);
        ontouch_object.removeChild(title);
        ontouch_object.removeChild(text1);
        ontouch_object.removeChild(text2);
    }

    //关闭按钮事件
    private closebtn2(): void {
        if (btnclose == false) {
            return;
        }
        closebtn = true;
        this.removeChild(container);
        // 重新请求邮箱数量
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/foot/user/getUserOpenId", egret.HttpMethod.GET);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.onGetMsg, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
        // history.go(0);
    }
    private onMoney(): void { //点击游戏币时跳转到商城
        // if (cannotbtn == false){

        //     alert("获取用户信息中，请稍等...");

        //     return
        // }
        if (closebtn == false) {
            return
        }
        if(lucklylock == false){
            return
        }
        this.buyMoney();
    }
    public addtips(text: string, isHistory: string): void {
        luckbtnclose = false;
        closebtn = false
        click_msg = false;
        clickbtn = false;
        ontouch = false;
        btnclose = false;
        var textX: number;
        if (text.length == 4) {
            // alert(text.length);
            textX = 200
        } else if (text.length == 3) {
            // alert(text.length);
            textX = 250
        } else if (text.length == 9) {
            // alert(text.length);
            textX = 140
        } else if (text.length == 13) {
            // alert(text.length);
            textX = 100
        } else if (text.length == 16) {
            // alert(text.length);
            textX = 70
        } else if (text.length == 12) {
            textX = 95
        }

        // tipscontainer.width = 350;
        // tipscontainer.height = 179;


        tipscontainer.width = 500;
        tipscontainer.height = 256;
        tipscontainer.x = 80;
        tipscontainer.y = 420;

        var tips: egret.Bitmap = new Bitmap();
        tips.texture = RES.getRes("tipsk_jpg");
        tips.width = 500;
        tips.height = 256;
        tips.name = isHistory;

        var tipText: egret.TextField = new egret.TextField();
        tipText.x = 220;
        tipText.y = 10;
        tipText.fontFamily = "KaiTi";
        tipText.textFlow = <Array<egret.ITextElement>>[
            {
                text: "提示",
                style: { "textColor": 0x000000, "size": 28, "fontFamily": "楷体" }
            }
        ];
        var tipText2: egret.TextField = new egret.TextField();
        tipText2.x = textX;
        tipText2.y = 100;
        tipText2.fontFamily = "KaiTi";
        tipText2.textFlow = <Array<egret.ITextElement>>[
            {
                // text: text,
                text: text,
                style: { "textColor": 0x778899, "size": 23, "fontFamily": "楷体" }
            }
        ];

        var shp: egret.Shape = new egret.Shape();
        shp.graphics.drawRect(0, 0, 500, 80);
        shp.y = 180;
        shp.graphics.endFill();
        // shp.name = isHistory;


        var tipText3: egret.TextField = new egret.TextField();
        tipText3.x = 220;
        tipText3.y = 210;

        tipText3.fontFamily = "KaiTi";
        // tipText3.name = isHistory;
        tipText3.textFlow = <Array<egret.ITextElement>>[
            {
                text: "确定",
                style: { "textColor": 0x008000, "size": 28, "fontFamily": "楷体" }
            }
        ];
        // tipText3.touchEnabled = true;
        tips.touchEnabled = true;
        this.addChild(tipscontainer);
        tipscontainer.addChild(tips);
        tipscontainer.addChild(shp);
        tipscontainer.addChild(tipText);
        tipscontainer.addChild(tipText2);
        tipscontainer.addChild(tipText3);

        // tipText3.addEventListener(egret.TouchEvent.TOUCH_TAP, this.touchOk, this);
        tips.addEventListener(egret.TouchEvent.TOUCH_TAP, this.touchOk, this);
    }
    public touchOk(evt: egret.Event): void {
        btnclose = true;
        closebtn = true;
        click_msg = true;
        clickbtn = true;
        ontouch = true;
        rechar = true;
        luckbtnclose = true
        var currentTarget: any = evt.currentTarget;
        this.removeChild(tipscontainer);
        if (currentTarget.name == "刷新") {
            history.go(0)
        } else if (currentTarget.name == "s不刷新") {
            this.buyMoney();
        } else if (currentTarget.name == "r不刷新") {
            this.gettask();
        }
    }




    public buyMoney(): void {  //充值商城
        if (closebtn == false || btnclose == false) {
            return
        }
        if(lucklylock == false){
            return
        }
        closebtn = false
        click_msg = false;
        clickbtn = false;
        ontouch = false;
        buy.texture = RES.getRes("buy5");
        buy.width = 150;
        buy.height = 197;
        buy.x = 47;
        buy.y = 450;
        //购买按钮 ----购买10元
        buy10.texture = RES.getRes("buy10");
        buy10.width = 150;
        buy10.height = 197;
        buy10.x = 250;
        buy10.y = 450;
        //购买按钮 ----购买50元
        buy50.texture = RES.getRes("buy50");
        buy50.width = 150;
        buy50.height = 197;
        buy50.x = 450;
        buy50.y = 450;
        //购买按钮 ----购买500元
        buy500.texture = RES.getRes("buy500");
        buy500.width = 150;
        buy500.height = 197;
        buy500.x = 55;
        buy500.y = 747;
        //购买按钮 ----购买1K元
        buy1k.texture = RES.getRes("buy1k");
        buy1k.width = 150;
        buy1k.height = 197;
        buy1k.x = 250;
        buy1k.y = 747;
        //购买按钮 ----购买2K元
        buy2k.texture = RES.getRes("buy2k");
        buy2k.width = 150;
        buy2k.height = 197;
        buy2k.x = 450;
        buy2k.y = 747;
        //关闭按钮
        close1.texture = RES.getRes("close");
        close1.width = 50;
        close1.height = 50;
        close1.x = 560;
        close1.y = 30;
        var recharge = egret.Tween.get(catalogTips).to({
            "width": 640,
            "height": 1150
        }, 200).call(function () {
            buy.touchEnabled = true;
            buy10.touchEnabled = true;
            buy50.touchEnabled = true;
            buy500.touchEnabled = true;
            buy1k.touchEnabled = true;
            buy2k.touchEnabled = true;
            ontouch_object.addChild(buy);
            ontouch_object.addChild(buy10);
            ontouch_object.addChild(buy50);
            ontouch_object.addChild(buy500);
            ontouch_object.addChild(buy1k);
            ontouch_object.addChild(buy2k);
            ontouch_object.addChild(close1);
        });
        close1.touchEnabled = true;
        close1.addEventListener(egret.TouchEvent.TOUCH_TAP, this.closeRecharge, this);
        buy.addEventListener(egret.TouchEvent.TOUCH_TAP, this.buy, this);
        buy10.addEventListener(egret.TouchEvent.TOUCH_TAP, this.buy10, this);
        buy50.addEventListener(egret.TouchEvent.TOUCH_TAP, this.buy50, this);
        buy500.addEventListener(egret.TouchEvent.TOUCH_TAP, this.buy500, this);
        buy1k.addEventListener(egret.TouchEvent.TOUCH_TAP, this.buy1k, this);
        buy2k.addEventListener(egret.TouchEvent.TOUCH_TAP, this.buy2k, this);
    }

    private changmusic(evt: egret.Event): void {
        // if (cannotbtn == false){
        //     return
        // }
        if (closebtn == false) {
            return
        }
        if(lucklylock == false){
            return
        }
        //  channel = sound.play(0, -1);
        if (musicplay == true) {
            channel.stop();
            musicbtns.texture = RES.getRes("close_music_png");
            musicbtns.width = 75;
            musicbtns.height = 75;
            musicbtns.y = 70;
            musicbtns.x = 443;
            musicplay = false;
        } else {
            channel = sound.play(0, -1);
            musicplay = true;
            musicbtns.texture = RES.getRes("open_music_png");
            musicbtns.width = 75;
            musicbtns.height = 75;
            musicbtns.y = 70;
            musicbtns.x = 443;
        }
    }




    // 转盘
    private luckdraw(): void {
        if (closebtn == false) {
            return
        }
        if(lucklylock == false){
            return
        }
        closebtn = false;
        luckcontainer.width = 480;
        luckcontainer.height = 480;
        // luckcontainer.x = 80;
        // luckcontainer.y = 200;
        luckcontainer.x = 80;
        luckcontainer.y = -480;
        var down = egret.Tween.get(luckcontainer).to({ y: 200 }, 500);
        // 转盘
        luckpic.texture = RES.getRes("turntable_png");
        luckpic.width = 480;
        luckpic.height = 480;
        // 指针
        var pointer: egret.Bitmap = new Bitmap();
        pointer.texture = RES.getRes("pointer_png");
        pointer.y = 70;
        pointer.x = 90;
        pointer.width = 300;
        pointer.height = 300;

        var closeluck: egret.Bitmap = new Bitmap();
        closeluck.texture = RES.getRes("close");
        closeluck.width = 50;
        closeluck.height = 50;
        closeluck.y = 0;
        closeluck.x = 430;
        closeluck.touchEnabled = true;
        pointer.touchEnabled = true;
        this.addChildAt(luckcontainer, 99);
        luckcontainer.addChild(luckpic);
        luckcontainer.addChild(pointer);
        luckcontainer.addChild(closeluck);
        closeluck.addEventListener(egret.TouchEvent.TOUCH_TAP, this.closeluck, this);
        pointer.addEventListener(egret.TouchEvent.TOUCH_TAP, this.luckrotation, this);
    }



    private closeluck(): void {
        if (luckclose == false) {
            return;
        }
        if (luckbtnclose == false) {
            return
        }
        if(lucklylock == false){
            return
        }
        lucklylock = true
        closebtn = true;
        var down = egret.Tween.get(luckcontainer).to({ y: -480 }, 500);
        // this.removeChild(luckcontainer);

    }

    private luckrotation(): void {
        if (luckbtnclose == false) {
            return
        }
        if(lucklylock == false){
            return
        }

        closebtn = false;
        //  rTimes =1;

        if (numberOfTurns == 0) {
            this.addtips("抽奖次数不足,请完成任务。", "r不刷新");
            this.removeChild(luckcontainer);
            return;
        }

        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/foot/user/getTurntableRecord", egret.HttpMethod.GET);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.getLuckInterface, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);



        luckbtnclose = false;
        luckclose = false;
        luckpic.anchorOffsetX = luckpic.width * 0.5
        luckpic.anchorOffsetY = luckpic.height * 0.5;
        luckpic.x = 240;
        luckpic.y = 240;
        var tw = egret.Tween.get(luckpic, { loop: true });
        tw.to({ rotation: 360 }, 400)
        var timer: egret.Timer = new egret.Timer(3000, 1);
        //注册事件侦听器
        // timer.addEventListener(egret.TimerEvent.TIMER, this.timerFunc, this);
        timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.timerComFunc, this);
        //开始计时
        timer.start();

    }

    private getLuckInterface(event: egret.Event): void {
        var request = <egret.HttpRequest>event.currentTarget;
        var req = JSON.parse(request.response);//转为JSON格式
        // console.log(req);
        prizesId = req.data.awardId
        rTimes = req.data.count;
        rname = req.data.awardContent
        commodityId = req.data.id;
        switch (prizesId) {
            case 1:
                rotations = 105;
                break;
            case 2:
                rotations = 325;
                break;
            case 3:
                rotations = 255;
                break;
            case 4:
                rotations = 285;
                break;
            case 5:
                rotations = 180;
                break;
            case 6:
                rotations = 35;
                break;
            case 7:
                rotations = 215;
                break;
            case 8:
                rotations = 145;
                break;
            case 9:
                rotations = 75;
                break;
            case 10:
                rotations = 360;
                break;
        }
    }

    // private timerFunc() {
    //     console.log("计时");
    //     console.log(luckpic.rotation);
    // }
    private timerComFunc() {
        // console.log(luckpic.rotation);
        egret.Tween.removeTweens(luckpic);
        // 360:一等奖
        // 125:二等奖
        // 295:三等奖
        // 360:谢谢参与
        // rotations
        // rotations = 215;
        // rotations = 360;
        var win: egret.Bitmap = new Bitmap();
        win.texture = RES.getRes("winthelottery_png");
        win.width = 1;
        win.height = 1;
        win.x = 120;
        win.y = 180;
        ontouch_object.addChildAt(win, 99);

        // prizesId
        egret.Tween.get(luckpic, { loop: false }).to({ rotation: rotations }, 1000, egret.Ease.cubicOut).call(function () {
            if (rname == "谢谢惠顾") {
                numberOfTurns = numberOfTurns - 1;
                //ID值(text)
                rotationTimes.x = 315;
                rotationTimes.y = 150;
                rotationTimes.textFlow = <Array<egret.ITextElement>>[
                    {
                        text: "抽奖次数(" + numberOfTurns + ")",//336699   0x6699cc
                        style: { "textColor": 0x000000, "size": 20, "fontFamily": "楷体" }
                    }
                ];
                ontouch_object.addtips(rname, "不刷新");
            } else if (rname == "再来一次") {
                ontouch_object.receivePrizes(rname, "不刷新");
            } else {
                egret.Tween.get(win).to({ "scaleX": 400, "scaleY": 222 }, 500).wait(1000).to({ "scaleX": 0.1, "scaleY": 0.1 }, 500);
                ontouch_object.receivePrizes("恭喜你获得" + rname, "不刷新");
            }

        })
        // this.addtips("恭喜你获取" + rname, "不刷新");
        // console.log("计时结束");
        luckclose = true;
        luckbtnclose = true;
        // winthelottery_png
    }

    private gettask() {
        if (closebtn == false) {
            return
        }
        closebtn = false;
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/foot/user/getMissionRecordNow", egret.HttpMethod.GET);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.onGetTask, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
        //显示对象容器，使用DisplayObjectContainer
        // var container = new egret.DisplayObjectContainer();
        //容器的缩放，旋转，位移将影响到它下面的子节点(即包含的显示对象)
        var myScroller = new eui.Scroller();
        taskcontainers.width = 400;
        taskcontainers.height = 711;
        taskcontainers.x = 120;
        taskcontainers.y = 150;
        taskcontainers.name = "任务"
        taskcontainer.x = 15;
        taskcontainer.y = 0;
        taskcontainer.width = 335;
        taskcontainer.height = msgheight;
        // var group = new eui.Group();
        // var img = new eui.Image("resource/rechargeBg.jpg");
        // group.addChild(img);
        //创建一个Scroller
        mytaskscrollView.setContent(taskcontainer);
        mytaskscrollView.x = 25;
        mytaskscrollView.y = 130;
        mytaskscrollView.width = 350;
        mytaskscrollView.height = 500;
        var loding_j = RES.getRes("lodingpic_json");
        var loding_i = RES.getRes("lodingpic_png");
        var loding_active = new egret.MovieClipDataFactory(loding_j, loding_i);
        loding_actives = new egret.MovieClip(loding_active.generateMovieClipData());
        loding_actives.gotoAndPlay(0, -1);
        loding_actives.x = -160;
        loding_actives.y = -100;
        closebtn = false;
        onexplainwindows2.texture = RES.getRes("taskbox_png");
        onexplainwindows2.width = 400;
        onexplainwindows2.height = 711;
        var closebtns: egret.Bitmap = new Bitmap();
        closebtns.texture = RES.getRes("close");
        closebtns.width = 50;
        closebtns.height = 50;
        closebtns.x = 355;
        closebtns.y = -5;
        closebtns.touchEnabled = true;
        clickreceives = false;
        taskcontainers.addChild(onexplainwindows2);
        taskcontainers.addChild(loding_actives);
        taskcontainers.addChild(mytaskscrollView);
        taskcontainers.addChild(closebtns);
        // container.addChild(title);
        this.addChild(taskcontainers);
        mssage_num = this;
        closebtns.addEventListener(egret.TouchEvent.TOUCH_TAP, this.taskclosebtn2, this);
    }


    private onGetTask(event: egret.Event): void {
        var request = <egret.HttpRequest>event.currentTarget;
        var req = JSON.parse(request.response);//转为JSON格式
        console.log(req);
        taskcontainers.removeChild(loding_actives);
        taskcontainer.removeChildren();
        if (req.error_code == 1) {
            var tiptext: egret.TextField = new egret.TextField();
            tiptext.x = 45;
            tiptext.y = 200;
            tiptext.width = 320;
            tiptext.textFlow = <Array<egret.ITextElement>>[
                {
                    text: "请重新扫码登录！",
                    style: { "textColor": 0xFFFFFF, "size": 30, "fontFamily": "楷体" }
                }
            ];
            // if (solcontainer.parent) {
            //     solcontainer.removeChild(textList);
            //     solcontainer.removeChild(receives);
            // }
            // solcontainer.removeChildren();
            taskcontainer.addChildAt(tiptext, 99);
            return
        }


        if (req.data.length != 0) {
            taskmessageList = req.data;
            taskmsgheight = req.data.length;//获取长度
            msgheight = taskmsgheight * 110;
            for (let i = 0; i < taskmsgheight; i++) {//行
                var timestamp3 = taskmessageList[i].createTime / 1000;
                var newDate = new Date();
                newDate.setTime(timestamp3 * 1000);
                var textList: egret.TextField = new egret.TextField();
                textList.width = 320;
                // textList.width = 560;
                textList.x = 20;
                textList.y = 0 + (i * 110);
                textList.textFlow = <Array<egret.ITextElement>>[
                    {
                        text: "任务" + (i + 1) + ":",
                        style: { "textColor": 0xFFFFFF, "size": 30, "fontFamily": "楷体" }
                    }, {
                        text: "\n时间：" + newDate.toLocaleString(),
                        style: { "textColor": 0xFFFFFF, "size": 20, "fontFamily": "楷体" }
                    }, {
                        text: "\n内容：" + taskmessageList[i].missionContent,
                        style: { "textColor": 0xFFFFFF, "size": 20, "fontFamily": "楷体" }
                    }
                ];
                var data = taskmessageList[i].gitMoney;
                var msgid = taskmessageList[i].id;

                if (taskmessageList[i].status == 1) {
                    var receives: egret.Bitmap = new Bitmap();
                    receives.name = "" + msgid;
                    receives.texture = RES.getRes("alreadyReceived_png");
                    receives.width = 100;
                    receives.height = 100;
                    receives.x = 220;
                    receives.y = 0 + (i * 110);
                    // receives.bitmapData = "?gitMoney="+messageList[i].gitMoney+"&id="+msgid;
                    // receives.touchEnabled = true;
                    // clickreceives = true;
                    // receives.addEventListener(egret.TouchEvent.TOUCH_TAP, this.taskOnTouch, this);
                    taskcontainer.addChildAt(textList, 99);
                    taskcontainer.addChildAt(receives, 99);
                } else {
                    var receives: egret.Bitmap = new Bitmap();
                    receives.name = "" + msgid;
                    receives.texture = RES.getRes("receive");
                    receives.width = 100;
                    receives.height = 31;
                    receives.x = 220;
                    receives.y = 0 + (i * 110);
                    // receives.bitmapData = "?gitMoney="+messageList[i].gitMoney+"&id="+msgid;
                    receives.touchEnabled = true;
                    clickreceives = true;
                    receives.addEventListener(egret.TouchEvent.TOUCH_TAP, this.taskOnTouch, this);
                    taskcontainer.addChildAt(textList, 99);
                    taskcontainer.addChildAt(receives, 99);
                }
            }
        } else {
            // msglength = 0;//获取长度
            var tiptext: egret.TextField = new egret.TextField();
            tiptext.x = 60;
            tiptext.y = 200;
            tiptext.width = 320;
            tiptext.textFlow = <Array<egret.ITextElement>>[
                {
                    text: "目前暂无任务！",
                    style: { "textColor": 0xFFFFFF, "size": 30, "fontFamily": "楷体" }
                }
            ];
            // if (solcontainer.parent) {
            //     solcontainer.removeChild(textList);
            //     solcontainer.removeChild(receives);
            // }
            // solcontainer.removeChildren();
            taskcontainer.addChildAt(tiptext, 99);
            // return;
        }

    }
    private taskclosebtn2(): void {
        if (btnclose == false) {
            return;
        }
        closebtn = true;
        this.removeChild(taskcontainers);
        // 重新请求邮箱数量
        // var request = new egret.HttpRequest();
        // request.responseType = egret.HttpResponseType.TEXT;
        // request.open(http_open + "/foot/user/getUserOpenId", egret.HttpMethod.GET);
        // request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        // request.send();
        // request.addEventListener(egret.Event.COMPLETE, this.onGetMsg, this);
        // request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        // request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
        // history.go(0);

    }
    private taskOnTouch(evt: egret.Event): void {
        if (clickreceives == false) {
            return;
        }
        var currentTarget: any = evt.currentTarget;
        event_task = currentTarget;


        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/foot/user/getMission?missionId=" + currentTarget.name, egret.HttpMethod.POST);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.getTaskMsg, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
        // if(taskString == null){
        //     currentTarget.texture = RES.getRes("receive");
        // }else{
        //     currentTarget.texture = taskString;
        // currentTarget.width   = taskStringWidth;
        // currentTarget.height  = taskStringHeight;
        // }
        // RES.getRes("alreadyReceived_png");
    }
    private getTaskMsg(event: egret.Event): void {
        var requests = <egret.HttpRequest>event.currentTarget;
        var req = JSON.parse(requests.response);//转为JSON格式
        // console.log(req);
        // 0成功 1失败 2已领取
        if (req.error_code == 0) {
            event_task.texture = RES.getRes('alreadyReceived_png');
            event_task.width = 100;
            event_task.height = 100;
            // var currentTarget: any = event.currentTarget;
            // currentTarget.texture = RES.getRes("alreadyReceived_png");
            this.addtips(req.data, "不刷新");
        } else {
            //  event_task.texture = RES.getRes('alreadyReceived_png');
            // event_task.width = 100;
            // event_task.height  = 100;
            event_task.texture = RES.getRes("receive");
            event_task.width = 100;
            event_task.height = 31;
            // taskString = RES.getRes('alreadyReceived_png');
            // taskStringWidth = 100;
            // taskStringHeight = 100;
            this.addtips("领取失败", "不刷新");

        }
    }

    public receivePrizes(text: string, isHistory: string): void {
        
        closebtn = false
        click_msg = false;
        clickbtn = false;
        ontouch = false;
        btnclose = false;
        lucklylock = false
           
        var textX: number;
        if (text.length == 4) {
            // alert(text.length);
            textX = 200
        } else if (text.length == 3) {
            // alert(text.length);
            textX = 250
        } else if (text.length == 9) {
            // alert(text.length);
            textX = 140
        } else if (text.length == 13) {
            // alert(text.length);
            textX = 100
        } else if (text.length == 16) {
            // alert(text.length);
            textX = 70
        } else if (text.length == 12) {
            textX = 95
        } else if (text.length == 8) {
            textX = 150
        }

        // tipscontainer.width = 350;
        // tipscontainer.height = 179;

        tipscontainer.width = 500;
        tipscontainer.height = 256;
        tipscontainer.x = 80;
        tipscontainer.y = 420;

        var tips: egret.Bitmap = new Bitmap();
        tips.texture = RES.getRes("tipsk_jpg");
        tips.width = 500;
        tips.height = 256;
        tips.name = isHistory;

        var tipText: egret.TextField = new egret.TextField();
        tipText.x = 220;
        tipText.y = 10;
        tipText.fontFamily = "KaiTi";
        tipText.textFlow = <Array<egret.ITextElement>>[
            {
                text: "提示",
                style: { "textColor": 0x000000, "size": 28, "fontFamily": "楷体" }
            }
        ];
        var tipText2: egret.TextField = new egret.TextField();
        tipText2.x = textX;
        tipText2.y = 100;
        tipText2.fontFamily = "KaiTi";
        tipText2.textFlow = <Array<egret.ITextElement>>[
            {
                // text: text,
                text: text,
                style: { "textColor": 0x778899, "size": 23, "fontFamily": "楷体" }
            }
        ];

        var shp: egret.Shape = new egret.Shape();
        shp.graphics.drawRect(0, 0, 500, 80);
        shp.y = 180;
        shp.graphics.endFill();
        // shp.name = isHistory;


        var tipText3: egret.TextField = new egret.TextField();
        tipText3.x = 220;
        tipText3.y = 210;

        tipText3.fontFamily = "KaiTi";
        // tipText3.name = isHistory;
        tipText3.textFlow = <Array<egret.ITextElement>>[
            {
                text: "领取",
                style: { "textColor": 0x008000, "size": 28, "fontFamily": "楷体" }
            }
        ];
        // tipText3.touchEnabled = true;
        tips.touchEnabled = true;
        this.addChild(tipscontainer);
        tipscontainer.addChild(tips);
        tipscontainer.addChild(shp);
        tipscontainer.addChild(tipText);
        tipscontainer.addChild(tipText2);
        tipscontainer.addChild(tipText3);

        // tipText3.addEventListener(egret.TouchEvent.TOUCH_TAP, this.touchOk, this);
        tips.addEventListener(egret.TouchEvent.TOUCH_TAP, this.touchGetPrizes, this);
    }
    public touchGetPrizes(evt: egret.Event): void {
        btnclose = true;
        closebtn = true;
        click_msg = true;
        clickbtn = true;
        ontouch = true;
        rechar = true;
        lucklylock = true;
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(http_open + "/foot/user/getUserAward?id=" + commodityId, egret.HttpMethod.POST);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send();
        request.addEventListener(egret.Event.COMPLETE, this.receiveResults, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
        request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);

        // var currentTarget: any = evt.currentTarget;
        // console.log(currentTarget);
        this.removeChild(tipscontainer);
        // this.addtips("领取成功","不刷新");

    }

    private receiveResults(event: egret.Event): void {
        var requests = <egret.HttpRequest>event.currentTarget;
        var req = JSON.parse(requests.response);//转为JSON格式

        if (req.error_code == 1) {
            this.addtips("领取失败", "不刷新");
        } else {
            numberOfTurns = req.data.count;
            // count
            rTimes = req.data.turnCount;
            rotationTimes.x = 315;
            rotationTimes.y = 150;
            rotationTimes.textFlow = <Array<egret.ITextElement>>[
                {
                    text: "抽奖次数(" + numberOfTurns + ")",//336699   0x6699cc
                    style: { "textColor": 0x000000, "size": 20, "fontFamily": "楷体" }
                }
            ];
            if (prizesId >= 7) {
                var imgUrl = req.data.value.awardImgUrl;
                var idUrl = req.data.value.awardId;
                // window.location.href = "/" + imgUrl + "?id=" + commodityId + "&awardId="+idUrl;
                window.location.href = "/text/index.html?id=" + commodityId + "&awardId="+idUrl;
            } else {
                this.addtips("领取成功", "不刷新");
            }

        }

    }

}


